1

This is getting list of orders from Orderhive API and it uses AWS4 Signature. With this code I am able to get the list of orders however I need to filter the order status to only get confirm orders. My problem is to get only confirm orders.

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) { }
}

Having forbidden error in get orders from Orderhive API when passing a filter to HttpRequestMessage.Content

Jen143
  • 815
  • 4
  • 17
  • 42

1 Answers1

0

Per the Documentation, it says the Filter goes as part of your Request's Body. So can you try this

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

Hope this helps!

Sathish Guru V
  • 1,417
  • 2
  • 15
  • 39