Skip to content
Snippets Groups Projects
Commit 58c25ff6 authored by Xebax's avatar Xebax
Browse files

REST API: fix the error 500 when updating a product.

parent 9f526c51
No related branches found
No related tags found
No related merge requests found
...@@ -88,6 +88,17 @@ class DolibarrApi ...@@ -88,6 +88,17 @@ class DolibarrApi
// Remove $db object property for object // Remove $db object property for object
unset($object->db); unset($object->db);
// Remove the $oldcopy property because it is not supported by the JSON
// encoder. The following error is generated when trying to serialize
// it: "Error encoding/decoding JSON: Type is not supported"
// Note: Event if this property was correctly handled by the JSON
// encoder, it should be ignored because keeping it would let the API
// have a very strange behavior: calling PUT and then GET on the same
// resource would give different results:
// PUT /objects/{id} -> returns object with oldcopy = previous version of the object
// GET /objects/{id} -> returns object with oldcopy empty
unset($object->oldcopy);
// If object has lines, remove $db property // If object has lines, remove $db property
if(isset($object->lines) && count($object->lines) > 0) { if(isset($object->lines) && count($object->lines) > 0) {
$nboflines = count($object->lines); $nboflines = count($object->lines);
......
...@@ -275,7 +275,6 @@ class Products extends DolibarrApi ...@@ -275,7 +275,6 @@ class Products extends DolibarrApi
* @param int $id Id of product to update * @param int $id Id of product to update
* @param array $request_data Datas * @param array $request_data Datas
* @return int * @return int
* FIXME The product is correctluy updated but the API returns an error 500.
*/ */
function put($id, $request_data = NULL) function put($id, $request_data = NULL)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment