How to get response from Walmart

Hello everybody,

today I want to share with the world another piece of code, producing of which took me significant amount of efforts, getting response from Walmart.

Yesterday I've posted code that signs provided by Walmart credentials.

And today I decided to post code that retrieves orders information from Walmart.

private void MakeRequests()
{
    HttpWebResponse response;

    if (Request_marketplace_walmartapis_com(out response))
    {
        response.Close();
    }
}

private bool Request_marketplace_walmartapis_com(out HttpWebResponse response)
{
    response = null;

    try
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://marketplace.walmartapis.com/v3/orders?createdStartDate=2016-08-16");

        request.Headers.Add("WM_SVC.NAME", "Walmart Marketplace");
        request.Headers.Add("WM_QOS.CORRELATION_ID", "123456abcdef");
        request.Headers.Add("WM_SEC.AUTH_SIGNATURE", "trimmed for security reasons");
        request.Headers.Add("WM_SEC.TIMESTAMP", "1495703564642");
        request.Headers.Add("WM_CONSUMER.ID", @"guid of customer that was provided to you by Walmart");
        request.Headers.Add("WM_CONSUMER.CHANNEL.TYPE", @"0f3e4dd4-0514-4346-b39d-af0e00ea066d");

        response = (HttpWebResponse)request.GetResponse();
    }
    catch (WebException e)
    {
        if (e.Status == WebExceptionStatus.ProtocolError) response = (HttpWebResponse)e.Response;
        else return false;
    }
    catch (Exception)
    {
        if(response != null) response.Close();
        return false;
    }

    return true;
}

In case if you'll have a need to make Walmart request, enjoy.

No Comments

Add a Comment