taophp Posted October 2, 2017 Posted October 2, 2017 Bonjour,J'essaie d'utiliser le web service de PrestaShop pour mettre à jour une commande afin d'indiquer un numéro de tracking transmise par un transporteur. Ce faisant, je rencontre une erreur que je ne comprends pas.Tout d'abord, je récupère toutes les associations commmande/transporteur.Requête: GET http://myshop.com/api/order_carriers Réponse: <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <order_carriers> <order_carrier id="1" xlink:href="http://myshop.com/api/order_carriers/1"/> <order_carrier id="2" xlink:href="http://myshop.com/api/order_carriers/2"/> [...] <order_carrier id="41" xlink:href="http://myshop.com/api/order_carriers/41"/> <order_carrier id="42" xlink:href="http://myshop.com/api/order_carriers/42"/> </order_carriers> </prestashop> J'affiche les informations dont je dispose sur la dernière.Requête: GET http://myshop.com/api/order_carriers/42 Réponse: <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <order_carrier> <id> <![CDATA[42]]> </id> <id_order xlink:href="http://myshop.com/api/orders/120"> <![CDATA[120]]> </id_order> <id_carrier xlink:href="http://myshop.com/api/carriers/1"> <![CDATA[1]]> </id_carrier> <id_order_invoice> <![CDATA[20]]> </id_order_invoice> <weight> <![CDATA[0.000000]]> </weight> <shipping_cost_tax_excl> <![CDATA[0.000000]]> </shipping_cost_tax_excl> <shipping_cost_tax_incl> <![CDATA[0.000000]]> </shipping_cost_tax_incl> <tracking_number></tracking_number> <date_add> <![CDATA[2017-09-25 11:04:00]]> </date_add> </order_carrier> </prestashop> Je fais une mise à jour en renvoyant les mêmes informations, en ajoutant seulement le numéro de tracking :Requête: PUT http://myshop.com/api/order_carriers/42 <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <order_carrier> <id> <![CDATA[42]]> </id> <id_order xlink:href="http://myshop.com/api/orders/120"> <![CDATA[120]]> </id_order> <id_carrier xlink:href="http://myshop.com/api/carriers/1"> <![CDATA[1]]> </id_carrier> <id_order_invoice> <![CDATA[20]]> </id_order_invoice> <weight> <![CDATA[0.000000]]> </weight> <shipping_cost_tax_excl> <![CDATA[0.000000]]> </shipping_cost_tax_excl> <shipping_cost_tax_incl> <![CDATA[0.000000]]> </shipping_cost_tax_incl> <tracking_number>123</tracking_number> <date_add> <![CDATA[2017-09-25 11:04:00]]> </date_add> </order_carrier> </prestashop> Réponse: <?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 OrderCarrier->id_order is not valid"]]> </message> </error> </errors> </prestashop> Mon id de commande n'est pas valide, paraît-il. Alors que je n'ai pas modifié cette information et que j'ai vérifié que l'id correspondant existe bel et bien.Requête: GET http://aw03.abw.lan/api/orders/120 Réponse: <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <order> <id> <![CDATA[120]]> </id> [...] <id_carrier xlink:href="http://myshop.com/api/carriers/1"> <![CDATA[1]]> </id_carrier> <current_state xlink:href="http://myshop.com/api/order_states/2"> <![CDATA[2]]> </current_state> [...] <invoice_number> <![CDATA[20]]> </invoice_number> <invoice_date> <![CDATA[2017-09-25 11:49:42]]> </invoice_date> <delivery_number> <![CDATA[0]]> </delivery_number> <delivery_date> <![CDATA[0000-00-00 00:00:00]]> </delivery_date> <valid> <![CDATA[1]]> </valid> <date_add> <![CDATA[2017-09-25 11:04:00]]> </date_add> <date_upd> <![CDATA[2017-09-25 11:49:51]]> </date_upd> <shipping_number notFilterable="true"></shipping_number> [...] <reference> <![CDATA[FZRUHKGDF]]> </reference> [...] </order> </prestashop> Je n'ai par ailleurs aucune autre erreur, y compris dans le log du serveur. Quelqu'un peut-il m'expliquer ce qui cloche et comment y remédier ? Share this post Link to post Share on other sites More sharing options...
olishop Posted October 2, 2017 Posted October 2, 2017 c'est peut-être parce que ce champ ne doit pas être indiqué dans la réponse. Supprimes l'entrée "id_order" de ton xml et essayes Share this post Link to post Share on other sites More sharing options...
taophp Posted October 2, 2017 Posted October 2, 2017 c'est peut-être parce que ce champ ne doit pas être indiqué dans la réponse. Supprimes l'entrée "id_order" de ton xml et essayes C'est un paramètre obligatoire. Voici la réponse que j'obtiens lorsque je le supprime : <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <errors> <error> <code> <![CDATA[41]]> </code> <message> <![CDATA[parameter "id_order" required]]> </message> </error> </errors> </prestashop> Share this post Link to post Share on other sites More sharing options...
symdev Posted September 9, 2021 Posted September 9, 2021 Bonjour ! Avez vous trouvé une solution ? Share this post Link to post Share on other sites More sharing options...
symdev Posted September 9, 2021 Posted September 9, 2021 J'ai fini par trouver (pour mon cas en tout cas) : je copiais collais le XML "pretty" et non "raw"... Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now