REST API: fix the error 500 when updating a product.
This commit is contained in:
parent
9f526c512d
commit
58c25ff665
@ -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
|
|||||||
* @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)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user