2

I am breaking my head trying to upload a feed to walmart, after many times trying i used postman to generate C# restsharp code for me, in postman it works, but when using the c# restsharp code it returns a mysterious error. like this: "No message body writer has been found for response class FeedAcknowledgement"

what does that mean?

here is my code:

 string requestUrl = "";
        requestUrl = string.Format("https://marketplace.walmartapis.com/v2/feeds?feedType=inventory");

        string method = "POST";

        // string[] sig = getSig(method, requestUrl).Replace("\r", "").Split('\n');

        var mySig = new Signature(ConsumerID, SecretKEY, requestUrl, method);
        var s = mySig.TimeStamp;
        var returendSigniture = mySig.GetSignature(s);

        var client = new RestClient("https://marketplace.walmartapis.com/v2/feeds?feedType=inventory");
        var request = new RestRequest(Method.POST);
        //request.AddHeader("postman-token", "c325ba5f-813a-f990-7899-6bfc4b14aa1b");
        request.AddHeader("cache-control", "no-cache");
        request.AddHeader("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
        request.AddHeader("accept", "application/xml");
        request.AddHeader("wm_consumer.id", "--");
        request.AddHeader("wm_sec.auth_signature", returendSigniture);
        request.AddHeader("wm_sec.timestamp", mySig.TimeStamp);
        request.AddHeader("wm_qos.correlation_id", "123456abcdef");
        request.AddHeader("wm_svc.name", "Walmart Marketplace");
        request.AddParameter("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW", "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"BOUNDERY\"\r\n\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<wm:inventory xmlns:wm=\"http://walmart.com/\">\n  <wm:sku>PP00500-2PC</wm:sku>\n  <wm:quantity>\n    <wm:unit>EACH</wm:unit>\n    <wm:amount>120</wm:amount>\n  </wm:quantity>\n  <wm:fulfillmentLagTime>1</wm:fulfillmentLagTime>\n</wm:inventory>\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--", ParameterType.RequestBody);
        IRestResponse response = client.Execute(request);
toastifer
  • 478
  • 3
  • 8
  • I have no idea why some useless bum decided to downgrade my question, I am working and researching this problem for 2 weeks, seems to be an empty warhead. besides the fact that there is nothing about walmart api on the web. – SpecialProgrammer May 05 '17 at 20:53

2 Answers2

0

I spent all day in figuring out how to request Walmart v3. I propose you the following two steps:

  1. Use Walmart signer in order to generate signed token.
  2. You will need to use HttpWebRequest for getting response from Walmart in a way similar to what is described here.
Yuriy Zaletskyy
  • 4,983
  • 5
  • 34
  • 54
0

I have not been able to get this to work natively in C#, but I do have a work around.

The Java SDK can successfully submit multi-part requests to Walmart. I wrote a wrapper around the SDK functions that can accept basic command line input to read a text file and send the appropriate call with attached files. From here, you can just call the .jar file (I do it via dynamically generated batch file) from your C# program and receive responses back via text file. This is a sub-optimal system, but it works reliably and when the choice was between updating inventory on 2000 items every day and using some dirty code, I went with the Java wrapper method. This will be replaced as soon as the C# SDK comes out, but I believe this is one of the reasons why the C# SDK may be being delayed.

This solution was used, only after spending about a week trying to get boundaries / streams / attachments to work in C# and having zero success. Cases were also submitted to walmart and I was able to work with some of their top tier engineering support staff and this problem completely stumped them. I was able to trace the Java SDK execution all the way down to a built in Maven / Java function that constructed the web request so there's something under the hood that Java is doing with a multi-part request that isn't immediately clear in C#.

Nate M.
  • 822
  • 6
  • 14