I'm trying to update a product using the web service, this is my request:
```
and this is the response:
```<?xml version="1.0" encoding="UTF-8"?>
<prestashop
xmlns:xlink="http://www.w3.org/1999/xlink">
<errors>
<error>
<code>
<![CDATA[85]]>
</code>
<message>
<![CDATA[Validation error: "Property Product->price is not valid"]]>
</message>
</error>
</errors>
</prestashop>
This is on a standard installation with standard sample data on version 1.7.5.2.
Hi @esistgut,
I used this script
<?php
$url = 'http://shop';
$ws = new PrestaShopWebservice(
$url,
'Key',
false);
$id = 54; //ID product Here
$timestamp_debut = microtime(true);
$xml = $ws->get(array('resource' => 'products', 'id' => $id));
//Unset readonly fields or buggy fields
unset($xml->product->position_in_category);
unset($xml->product->manufacturer_name);
unset($xml->product->associations->product_features);
unset($xml->product->quantity);
unset($xml->product->associations->categories);
unset($xml->product->type);
$product = $xml->children()->children();
$product->price = 1.121;
$opt['putXml'] = $xml->asXML();
$opt['id'] = $id;
$opt['resource'] = 'products';
$xml = $ws->edit($opt);
echo "DONE";
And it is OK.
Thanks to check & feedback
I am not consuming the web service from a PHP client so I can't provide feedback on your test.
I found the problem on my end: spaces and newlines. This is working:
<prestashop
xmlns:xlink="http://www.w3.org/1999/xlink">
<product>
<id><![CDATA[1]]></id>
<price><![CDATA[25.00]]></price>
</product>
</prestashop>
Are you planning a proper rest/json/openapi or maybe graphql API in your roadmap?
@esistgut, thanks for your feedback.
No, it is not planned yet.
The API only supports XML on input but supports JSON output if you choose:
http://[email protected]/api?output_format=JSON
Since it is fixed, I close the issue.
Feel free to open a new one when needed.
Thanks!
Most helpful comment
I am not consuming the web service from a PHP client so I can't provide feedback on your test.
I found the problem on my end: spaces and newlines. This is working:
Are you planning a proper rest/json/openapi or maybe graphql API in your roadmap?