0

The eBay CSV Manager enables to upload a CSV file to mark all paid and sent items as sent in eBays seller tool. My Excel Macro creates such a CSV file. Now, I want to upload this file via HTTP Post Request.

In eBays CSV Manager manual they say:

Files can only be uploaded via Token. This Token has to be send with the file every upload. It is virtually the key for the entry to the CSV Manager.

I already have the Token.

It goes on to say that

a HTTP Post request has to be sent to the eBay CSV Manager Server to upload the file via script. The HTTPS connection has to be started and the data has to be send together with the Token to the CSV Manager web adress https://bulksell.ebay.com/ws/eBayISA...ExchangeUpload

eBay has an example for the request in its CSV Manager manual:

POST /path/to/upload/script HTTP/1.0

Connection: Keep-Alive

User-Agent: My Client App v1.0

Host:

https://bulksell.ebay.com/ws/eBayISA...ExchangeUpload

Content-type: multipart/form-data;

boundary=THIS_STRING_SEPARATES

Content-Length: 256

--THIS_STRING_SEPARATES

Content-Disposition: form-data; name="token"

12345678987654321

--THIS_STRING_SEPARATES

Content-Disposition: form-data; name="file";

filename="listings.csv"

Content-Type: text/csv

... contents of listings.csv ...

--THIS_STRING_SEPARATES

The explanation of the example is:

State which method has to be applied to the ressource:

POST /path/to/upload/script HTTP/1.0

Connection type, user-agent and information to the host:

Connection: Keep-Alive

User-Agent: My Client App v1.0

Host:https://bulksell.ebay.com/ws/eBayISA...ExchangeUpload

Header with information to the content and the lenght of the file:

Content-type: multipart/form-data; boundary=THIS_STRING_SEPARATES

Content-Length: 256

Safety Token and content to be uploaded:

--THIS_STRING_SEPARATES

Content-Disposition: form-data; name="token"

12345678987654321

--THIS_STRING_SEPARATES

Content-Disposition: form-data; name="file"; filename="listings.csv"

Content-Type: text/csv

... contents of listings.csv ...

--THIS_STRING_SEPARATES

How to do the HTTP Request and how to integrate it to the VBA Code?

T. P.
  • 101
  • 1
  • 9

1 Answers1

0

The concept of REST API is that you post a data file to the API end point. You need to use one of microsoft http add-on to conscruct the payload which contains the header and body and post it to the require API.

You would have multi part in your macro to achieve this function

  1. A login function where you would store the token
  2. A body constructor where you would read your excel data and transform it into a json format.
  3. A header constructor
  4. A post function where post the relevant data to the gateway api using the microsoft http document handler.

But if you are planning to send the CSV as data then its best to write a vbscript to quickly post the file to the API.