通过Web服务API更新中的Prestashop订单状态 [英] Updating order status in Prestashop via webservice api

查看:1004
本文介绍了通过Web服务API更新中的Prestashop订单状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做什么错在这里?

首先,我提出一个要求让现有的秩序,我改变得到的XML CURRENT_STATUS字段的值。然后,我让与修改后的XML的PUT请求作为参数,但我得到这样的回应:

First I make a request to get an existing order and I change the value of current_status field in retrieved xml. Then I make a PUT request with modified xml as a parameter but I get something like this in response:

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<errors>
<error>
<code><![CDATA[127]]></code>
<message><![CDATA[XML error : String could not be parsed as XML
XML length : 2864
Original XML : xml=%3C%3Fxml+version%3D%221%2E0%22+encoding...%3C%2Fprestashop%3E%0A]]></message>
</error>
</errors>
</prestashop>

在调试我的代码中有与ececution之前PUT请求XML参数没有问题。 Whay不那么原始XML显示XML ecoded像这样?我必须设置某种编码?我的代码是在C#。

When I debug my code there is no problem with xml parameter in the PUT request before ececution. Whay does then 'Original XML' show xml ecoded like so? Do I have to set some kind of encoding? My code is in C#.

推荐答案

似乎XML参数必须是类型RequestBody的。如果没有指定,将自动设置为输入GetOrPost这是造成'字符串不能被解析为XML的错误。 。我不知道如何一切正常,但似乎这是解决问题的办法。

It seems that xml parameter has to be of type RequestBody. If not specified it is automatically set to type GetOrPost which is causing 'String could not be parsed as XML' error. I'm not sure how everything works but it seems that this is the solution to the problem.

RestRequest request;
request = new RestRequest("api/orders/" + orderID, Method.GET);
IRestResponse response = client.Execute(request);

XElement orderXML = XElement.Parse(response.Content);
XElement orderEl = orderXML.Descendants().FirstOrDefault();
orderEl.Element("current_state").Value = "10";    

request = new RestRequest("api/orders", Method.PUT);
request.AddParameter("xml", orderXML.ToString(), ParameterType.RequestBody);
IRestResponse response2 = client.Execute(request);

这篇关于通过Web服务API更新中的Prestashop订单状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆