cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error Uploading File with Sell Feed API

Hello.

 

I am trying to upload a file of type LMS_REVISE_INVENTORY_STATUS via the Sell Feed API.  I first created a task with feed type LMS_REVISE_INVENTORY_STATUS and received a URL location of:

 

https://api.sandbox.ebay.com/sell/feed/v1/task/<TASK ID>

 

If it matters, I created the task with schemaVersion 1235.  I can't remember where I got that version.  (I really don't know where the schemaVersion comes from, so I'd appreciate help with that as well.)

 

I am then attempting to post to the above URL using the following code (C#):

 

 

using (HttpClient httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);
                httpClient.DefaultRequestHeaders.Add("X-EBAY-C-MARKETPLACE-ID", "EBAY_US");

                var httpContent = new MultipartFormDataContent();
                httpContent.Add(new ByteArrayContent(File.ReadAllBytes(filename)), "file");
                httpContent.Add(new StringContent(Path.GetFileName(filename)), "fileName");
                httpContent.Add(new StringContent("file"), "name");
                httpContent.Add(new StringContent("form-data"), "type");

                Task<HttpResponseMessage> task = httpClient.PostAsync(uploadURL, httpContent);
                task.Wait();
                HttpResponseMessage response = task.Result;

                var responseString = response.Content.ReadAsStringAsync().Result;
            }

 

 

Here is my file:

 


  ‌‌apis:eBLBaseComponents">
    en_US
    High
    
      1********8
      2
    
  

 

 The error I am receiving is:

 

{
  "errors": [
    {
      "errorId": 2004,
      "domain": "ACCESS",
      "category": "REQUEST",
      "message": "Invalid request",
      "longMessage": "The request has errors. For help, see the documentation for this API."
    }
  ]
}

 

Can anyone please tell me what I am doing wrong?

 

Thanks!

Message 1 of 3
latest reply
1 BEST ANSWER

Accepted Solutions

Error Uploading File with Sell Feed API

I managed to get it working.  For anyone else who comes up against this, here is the code that works:

 

            string filename = Path.GetFileName(filepath);

            using (HttpClient httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);

                var httpContent = new MultipartFormDataContent();
                httpContent.Add(new StringContent(File.ReadAllText(filepath)), "file", filename);
                httpContent.Add(new StringContent(filename), "fileName");
                httpContent.Add(new StringContent("file"), "name");
                httpContent.Add(new StringContent("form-data"), "type");

                Task<HttpResponseMessage> task = httpClient.PostAsync(uploadURL, httpContent);
                task.Wait();
                HttpResponseMessage response = task.Result;

                bool succeeded = response.StatusCode == HttpStatusCode.OK;
            }

View Best Answer in original post

Message 3 of 3
latest reply
2 REPLIES 2

Error Uploading File with Sell Feed API

The XML file did not format correctly in the above post.  Here is the full XML:

 

<?xml version="1.0" encoding="UTF-8"?>
<BulkDataExchangeRequests>
  <ReviseInventoryStatusRequest xmlns="urn:ebay:apis:eBLBaseComponents">
    <ErrorLanguage>en_US</ErrorLanguage>
    <WarningLevel>High</WarningLevel>
    <InventoryStatus>
      <ItemID>1XXXXXXXXX8</ItemID>
      <Quantity>2</Quantity>
    </InventoryStatus>
  </ReviseInventoryStatusRequest>
</BulkDataExchangeRequests>
Message 2 of 3
latest reply

Error Uploading File with Sell Feed API

I managed to get it working.  For anyone else who comes up against this, here is the code that works:

 

            string filename = Path.GetFileName(filepath);

            using (HttpClient httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);

                var httpContent = new MultipartFormDataContent();
                httpContent.Add(new StringContent(File.ReadAllText(filepath)), "file", filename);
                httpContent.Add(new StringContent(filename), "fileName");
                httpContent.Add(new StringContent("file"), "name");
                httpContent.Add(new StringContent("form-data"), "type");

                Task<HttpResponseMessage> task = httpClient.PostAsync(uploadURL, httpContent);
                task.Wait();
                HttpResponseMessage response = task.Result;

                bool succeeded = response.StatusCode == HttpStatusCode.OK;
            }
Message 3 of 3
latest reply