Need help to send a HTTP POST request to Ebay File Exchange

EBay File exchange is a system that allows uploading auction information programmatically.

The info to upload goes into a csv file.

The Ebay users manual explains:

•To upload your files programmatically, you must send an HTTP POST request to https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeUpload. This request will enable you to upload your files.

I have attached their example. This code should work:
SampleEbayPostRequestFromManual.txt

My code does not work:
FileExchangeCodeNoteWorking.txt

The code is in an event procedure for Access 2K  Pleas  advise.
pcalabriaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KimputerCommented:
Can you try to fix this typo first ?
"Content-Disostion: "

Open in new window

0
pcalabriaAuthor Commented:
Thanks.  I actually caught that error but did not correct my posting.  Here's a printout of ?strPostString.

POST /path/to/upload/script HTTP/1.0
Connection: Keep-Alive
User-Agent: My Client App v1.0
Host:https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeUpload
Content-type: multipart/form-data; boundary=THIS_STRING_SEPARATES Content-Length: 256
--THIS_STRING_SEPARATES
Content-Disposition: form-data; name="token" <token was here>--THIS_STRING_SEPARATES
Content-Disposition: form-data; name="file"; FileName="//Fileserverpro/database/Export/eBay/Reels for all inventory-1.csv"
Content-Type: text/csv
..contents of listing.csv...
--THIS_STRING-SEPARATES-
0
KimputerCommented:
Trry this first?
FileName="file://Fileserverpro/database/Export/eBay/inventory-1.csv"

Open in new window

So I want  file:// and also first test with a file without spaces in the name.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Also: Your code has single quotes around the filename:

strPostString = strPostString & "Content-Disostion: form-data; name='file'; FileName =  '" & strFileName & "' Content-Type: text/csv " & "contents of listing.csv .. "

Try removing those:

strPostString = strPostString & "Content-Disostion: form-data; name='file'; FileName =  " & strFileName & " Content-Type: text/csv " & "contents of listing.csv .. "
0
pcalabriaAuthor Commented:
Still no luck.  Here's a printout of the strPostString variable.  Note that I tried with and without the word file before the filename.

POST /path/to/upload/script HTTP/1.0
Connection: Keep-Alive
User-Agent: My Client App v1.0
Host:https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeUpload
Content-type: multipart/form-data; boundary=THIS_STRING_SEPARATES Content-Length: 256
--THIS_STRING_SEPARATES
Content-Disposition: form-data; name="token" <MyTokenWasHere>--THIS_STRING_SEPARATES
Content-Disposition: form-data; name="file"; FileName="file://Fileserverpro/database/Export/eBay/Reels.csv"
Content-Type: text/csv
..contents of listing.csv...
--THIS_STRING-SEPARATES-
0
KimputerCommented:
The strPostString is not correct, it should look like this:

POST /path/to/upload/script HTTP/1.0
 Connection: Keep-Alive
 User-Agent: My Client App v1.0
 Host:https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeUpload
 Content-type: multipart/form-data; boundary=THIS_STRING_SEPARATES Content-Length: 256
 --THIS_STRING_SEPARATES
 Content-Disposition: form-data; name="token" <MyTokenWasHere>--THIS_STRING_SEPARATES
 Content-Disposition: form-data; name="file"; FileName="file://Fileserverpro/database/Export/eBay/Reels.csv"
 Content-Type: text/csv
a,b,c,d
1,2,3,4
1,2,3,4
1,2,3,4
1,2,3,4
1,2,3,4
1,2,3,4
1,2,3,4
1,2,3,4
1,2,3,4
1,2,3,4
1,2,3,4
1,2,3,4
 --THIS_STRING-SEPARATES-


You mistook "..contents of listing.csv..." for a string. But it should be your app really reading this data from that file, and then using the content to be posted.
0
pcalabriaAuthor Commented:
Kimputer,

I'm not sure what data you are referring to.  The csv file includes about 400 rows of data, and perhaps 10 columns.

Does it seem to make sense that I need to send the rows one by one, even though I specified the csv file name?

I"m just confused, and what is a,b,c,d, 1,2,3,4 the data in the columns?  Is a,b,c,d the header names?

Thanks
0
KimputerCommented:
It was an example, as I do not know the real content of the CSV file in question.

Your app should read the content of that file, and paste it just like I showed you as an example.
Where I said a,b,c,d and 1,2,3,4. paste the content of that csv file.
0
pcalabriaAuthor Commented:
I'll give it a try this morning.  I will assume a,b,c,d are column names, and 1, 2,3, 4 corresponding data.
Thanks
0
pcalabriaAuthor Commented:
I'm still stuck.  The following error is returned:

?strPostResponse
This link is applicable only for programmatically upload. Otherwise the token you have entered may be wrong, please verify and upload again.
-----------------------------------------------------------------------------------------------------------------------
Here is my code:
objRequest.Open "POST", strPostURL, False
objRequest.Send strPostString
strPostResponse = objRequest.ResponseText

-----------------------------------------------------------------------------------------------------------------------
Here is strPostString:
POST /path/to/upload/script HTTP/1.0
Connection: Keep-Alive
User-Agent: My Client App v1.0
Host:https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeUpload
Content-type: multipart/form-data; boundary=THIS_STRING_SEPARATES Content-Length: 256
--THIS_STRING_SEPARATES
Content-Disposition: form-data; name="token" <MyCorrectTokenWasHere>
--THIS_STRING_SEPARATES
Content-Disposition: form-data; name="file"; FileName="//Fileserverpro/database/Export/eBay/Reels.csv"
Content-Type: text/csv
*Action(SiteID=US|Country=US|Currency=USD|Version=745),ItemID,*Title
Revise,281650426188,9846-PCS RESISTOR 0402 68 OHM 5% 200PPM 50V 1/16W STANDARD PERFOMANCE THICK FI
--THIS_STRING-SEPARATES

-----------------------------------------------------------------------------------------------------------------------
@Kimputer: I've tried with and without file:
Also, don't blame me for the quirky row names (*Action..., and *Title).  These are specified by Ebay.

The code attached to the original question shows an example from the Ebay manual (SampleEbayPostRequestFromManual.txt)
0
pcalabriaAuthor Commented:
Can anyone help with this?

I'm trying to send a file to Ebay's File Exchange server.
My original question contains sample code for sending a Post to Ebay's File Exchange server.

My code is in ID: 40706269 that does not work.  It returns the message:
This link is applicable only for programmatically upload. Otherwise the token you have entered may be wrong, please verify and upload again

Ebay has confirmed that my token is correct and valid.
0
KimputerCommented:
Try again with this code:

Dim objRequest As New MSXML2.XMLHTTP
Dim strPostString As String
Dim strPostURL As String
Dim strToken As String
Dim strFileName As String
Dim strPostResponse As String


strFileName = "\\Fileserverpro\database\Export\eBay\" & "Reels.csv"

strPostURL = "https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeUpload"
strToken = "I enter my token here"

strPostString = strPostString & "--THIS_STRING_SEPARATES" & vbCrLf
strPostString = strPostString & "Content-Disposition: form-data; name='token' " & strToken & vbCrLf

strPostString = strPostString & "--THIS_STRING_SEPARATES" & vbCrLf
strPostString = strPostString & "Content-Disposition: form-data; name='file'; FileName='" & strFileName & "'" & vbCrLf & "Content-Type: text/csv " & vbCrLf

strPostString = strPostString & "*Action(SiteID=US|Country=US|Currency=USD|Version=745),ItemID,*Title" & vbCrLf
strPostString = strPostString & "Revise,281650426188,9846-PCS RESISTOR 0402 68 OHM 5% 200PPM 50V 1/16W STANDARD PERFOMANCE THICK FI" & vbCrLf
 
strPostString = strPostString & "--THIS_STRING_SEPARATES"

objRequest.Open "POST", strPostURL, False
objRequest.setRequestHeader "Content-Type", "multipart/form-data; boundary=THIS_STRING_SEPARATES"
objRequest.Send strPostString

Open in new window

0
pcalabriaAuthor Commented:
Okay, I think we are making progress because I'm getting a different error message and the current message acknowledges that it received a File Exchange request:

Your File Exchange upload failed because a valid token is missing.


To get my token I went to page 65 of the advanced users guide, and clicked on  Grant Application Access - File Exchange page.  I was asked to enter my password and then copied the token using ctrl-c, and then pasted it directly into my code.

Can there be something going on with the paste operation?
0
KimputerCommented:
Slight change (near token):

Dim objRequest As New MSXML2.XMLHTTP
Dim strPostString As String
Dim strPostURL As String
Dim strToken As String
Dim strFileName As String
Dim strPostResponse As String


strFileName = "\\Fileserverpro\database\Export\eBay\" & "Reels.csv"

strPostURL = "https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeUpload"
strToken = "I enter my token here"

strPostString = strPostString & "--THIS_STRING_SEPARATES" & vbCrLf
strPostString = strPostString & "Content-Disposition: form-data; name='token' " & vbCrLf
strPostString = strPostString & strToken & vbCrLf
strPostString = strPostString & "--THIS_STRING_SEPARATES" & vbCrLf
strPostString = strPostString & "Content-Disposition: form-data; name='file'; FileName='" & strFileName & "'" & vbCrLf & "Content-Type: text/csv " & vbCrLf

strPostString = strPostString & "*Action(SiteID=US|Country=US|Currency=USD|Version=745),ItemID,*Title" & vbCrLf
strPostString = strPostString & "Revise,281650426188,9846-PCS RESISTOR 0402 68 OHM 5% 200PPM 50V 1/16W STANDARD PERFOMANCE THICK FI" & vbCrLf
 
strPostString = strPostString & "--THIS_STRING_SEPARATES"

objRequest.Open "POST", strPostURL, False
objRequest.setRequestHeader "Content-Type", "multipart/form-data; boundary=THIS_STRING_SEPARATES"
objRequest.Send strPostString

Open in new window

0
pcalabriaAuthor Commented:
Thanks for staying with this, but still no luck.
Getting the message: Your File Exchange upload failed because a valid token is missing.

I called eBay who recreated a new token, and it still does not work.

Just wondering, have you ever seen a file exchange programmatic upload work?  I'm wondering whether the eBay system may be broken.
0
KimputerCommented:
Another change to keep with standards (no '-characters but "-characters), and also shorten file name.

Dim objRequest As New MSXML2.XMLHTTP
Dim strPostString As String
Dim strPostURL As String
Dim strToken As String
Dim strFileName As String
Dim strPostResponse As String


strFileName = "Reels.csv"

strPostURL = "https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeUpload"
strToken = "I enter my token here"

strPostString = strPostString & "--THIS_STRING_SEPARATES" & vbCrLf
strPostString = strPostString & "Content-Disposition: form-data; name=""token""" & vbCrLf
strPostString = strPostString & strToken & vbCrLf
strPostString = strPostString & "--THIS_STRING_SEPARATES" & vbCrLf
strPostString = strPostString & "Content-Disposition: form-data; name=""file""; FileName=""" & strFileName & """" & vbCrLf & "Content-Type: text/csv" & vbCrLf

strPostString = strPostString & "*Action(SiteID=US|Country=US|Currency=USD|Version=745),ItemID,*Title" & vbCrLf
strPostString = strPostString & "Revise,281650426188,9846-PCS RESISTOR 0402 68 OHM 5% 200PPM 50V 1/16W STANDARD PERFOMANCE THICK FI" & vbCrLf
 
strPostString = strPostString & "--THIS_STRING_SEPARATES"

objRequest.Open "POST", strPostURL, False
objRequest.setRequestHeader "Content-Type", "multipart/form-data; boundary=THIS_STRING_SEPARATES"
objRequest.Send strPostString

Open in new window


Also please note, that if you login into ebay and you're in another country, the .com part changes. If that's true in your case, the .com in the code also needs to change (changes to .de for German users, for instance).

I've seen other code around that uses a login url (needs ebay username/password) before this upload code is fired. Is that in any of your documentation?
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Just wondering, have you ever seen a file exchange programmatic upload work?  I'm wondering whether the eBay system may be broken.
I have a client who does this regularly, but not with Access. They use .NET, which is far easier to use when working with web services and such.
0
pcalabriaAuthor Commented:
@Kimputer
Thanks, I will try ASAP

@Scott
Thanks, that's great news.  It's just a post right, so if it works with .NET and I do the same thing in Access I would think the file exchange server would never know the difference!  Good info.
0
KimputerCommented:
Not totally correct, in .NET you have slightly better libraries, including cookie control etc (so you can add authentication etc).
0
pcalabriaAuthor Commented:
@Kimputer
Did NOT solve the problem.  :-(
Your File Exchange upload failed because a valid token is missing.
Also, eBay Advanced App Support (Lance) verified that my token (should) be correct.  At least I'm getting it the correct place and it looks correct to him.  I have never seen it work, however.

Here is a debug.print of my code:
?strpoststring
--THIS_STRING_SEPARATES
Content-Disposition: form-data; name="token"
<<My Token Was Here. Very long string of ASCII characters>>
--THIS_STRING_SEPARATES
Content-Disposition: form-data; name="file"; FileName="Reels.csv"
Content-Type: text/csv
*Action(SiteID=US|Country=US|Currency=USD|Version=745),ItemID,*Title
Revise,281650426188,9846-PCS RESISTOR 0402 68 OHM 5% 200PPM 50V 1/16W STANDARD PERFOMANCE THICK FI
--THIS_STRING_SEPARATES
0
KimputerCommented:
Because the response from the server (token incorrect), and the support guy says it's correct, the only thing I can think of is that the token was copied & pasted maybe with an extra space (before or after the token).
0
pcalabriaAuthor Commented:
I've double checked the token, even recopied it from the bottom up as well as top down and the code still doesn't work.  I forwarded the code to Ebay yesterday in an attempt to get help, although Ebay does not support programmatic uploads.

They also don't give a working example.

Does anyone know some other way to programmatically post this code, using something other than VBA?  Perhaps I can execute the code through some other technology to see if it works with my token.  Someone mentioned a program named curl???
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You might try using something like Fiddler, which gives you a very detailed view of the comings and goings of internet traffic on your machine. I've used it to troubleshoot issues in connecting with web services:

http://www.telerik.com/fiddler

It was recently acquired by Telerik, which is why it lives there :)

Other than that - I've never had much luck dealing with web services from VBA. I found it much, much easier to use .NET to do this. I created something similar for a customer who needed to post files to a web service from Access - I muddled around with the various methods and techniques in VBA for a few days, and finally had enough. I created a small .exe in .NET that monitored a folder, and then created a routine in Access to output to that folder. When the .NET exe was triggered, it connected to the web service and moved the file over. .NET has builtin support for connecting with web services, and I spent about 3 hours creating the entire .NET project (and I had little experience with .NET at the time). It's still working to this day.

Moral of this story (and my ongoing mantra here on EE): Use the right tool for the job, and you'll find your life much, much easier :)
0
pcalabriaAuthor Commented:
Just wanted to send this update...
Ebay has provided me with some code that I can open with a browser to perform the post.
I pasted my token into the file, opened it with chrome, and everything worked.
So this means the token is correct.

The VGA code still provided the same error message, which indicates the token is not valid.
I'm waiting to hear what Ebays response to my test will be.
0
pcalabriaAuthor Commented:
This is still a problem.  
Ebay tech support has provided me with working code that uses my token to prove it is not a token problem.
I've opened a new question asking how to create access code from the working file provided.

The question ID is 28666935

Your continued help is desired.  I don't know how to close this thread.

Thanks
0
KimputerCommented:
take the last piece of code I posted, but change:

strPostURL = "https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeUpload"

to

strPostURL = "http://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeUpload"

That's basically the only change I see. If you use the HTML file on another computer (no saved password), do you need to login, or is the file uploaded WITHOUT login?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTTP Protocol

From novice to tech pro — start learning today.