0

这是从Orderhive API获取订单列表,它使用AWS4 Signature. 使用此代码,我可以获得订单列表,但是我需要过滤订单状态以仅获取confirm订单。我的问题是只得到确认订单。

public void GetOrdersFromOrderHiveNewVersion(List<Order> orders, string nexttoken="")
{
    _credentails = Authentication1();
    try
    {
        OAuthBase oAuth = new OAuthBase();
        var endPoint = "https://api.orderhive.com/orders/salesorder";
        if (!string.IsNullOrEmpty(nexttoken))
            endPoint = string.Format("{0}?next_token={1}", endPoint, nexttoken);

        // 0. Prepare request message.
        HttpRequestMessage msg = new HttpRequestMessage(HttpMethod.Post, endPoint);
        oAuth.AWSSignature(msg, _credentails);

        var filterObj = new Filters();
        var statFilter = new StatusFilter();
        string[] stat = new string[] { "confirm"};
        statFilter.order_status = stat;
        filterObj.filters = statFilter;
        var stringPayload = JsonConvert.SerializeObject(filterObj);
        var httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/json");
        msg.Content = httpContent;

        HttpClient client = new HttpClient();
        HttpResponseMessage result = client.SendAsync(msg).Result;
    }
    catch (Exception ex) { }
}

将过滤器传递给 HttpRequestMessage.Content 时,从 Orderhive API 获取订单时出现禁止错误

4

1 回答 1

0

根据文档,它说过滤器是您请求正文的一部分。所以你能试试这个

msg.Content = httpContent;
HttpClient client = new HttpClient();
HttpResponseMessage result = client.SendAsync(msg).Result;

希望这可以帮助!

于 2020-02-13T02:33:26.917 回答