0

I'm trying to develop a console app using C# where I can Update the data existing of Walmart product. But while I was reading the documentation of bulk updating promotion I could not figure out what are the requirements of request body. Here is the documentation of promotion https://developer.walmart.com/api/us/mp/promotion#operation/updateBulkPromotionalPrice . All I could figure out is that I need to pass the feed file. But whenever I'm trying to do so the API always returning status-code 520. Here is my approach

public static void CreateOffer()
        {

            /*
             * Code for generating json string
             */
           
            string filePath = "C:\\Data\\Price-Specific.xlsx";
            var filename = Path.GetFileName(filePath);
            byte[] fileBytes;
            using (FileStream stream = new FileStream(filePath, FileMode.Open))
            {
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    stream.CopyTo(memoryStream);
                    fileBytes = memoryStream.ToArray();
                }
            }
            marketplaceProviderService.CreateOfferToWalmart(filename,fileBytes);
            Console.WriteLine("Successfuly Added Promo");
}

Here is body of CreateOfferToWalmart() to fetch response from API

public void CreateOfferToWalmart(string fileName,byte[] fileByte)
        {
            this.FileName = fileName;
            this.FileBytes = fileByte;
            //this.walmart = new Provider.Walmart();
            this.walmart.CreateOffer(this);
            if (this.IsSuccessful)
            {
                var content = this.ProviderResponse;
            }
        }

Which also goes by the CreateOffer() which has all the headers and query parameter. I'm using RestSharp package.

public IMarketplace CreateOffer(IMarketplace marketplace)
        {
            this.SetRequest("feeds", Method.POST);
            this.request.AddQueryParameter("feedType", "promo");
            //this.request.AddJsonBody(marketplace.JsonBody);
            this.request.AddFileBytes("file", marketplace.FileBytes, marketplace.FileName);
            var response = this.MakeRequest();
            marketplace.ProviderResponse = response;
            marketplace.IsSuccessful = response.IsSuccessful;
            return marketplace;
        }

I could not figure out what I'm doing wrong

0 Answers0