We help IT Professionals succeed at work.

Can I use MS Access to send an HTTP Post and Get

3,073 Views
Last Modified: 2014-09-15
Hello Experts,

I am trying to use the programmatic upload feature of eBay's File Exchange system to send a CSV file to eBay's file exchange server.

I am hoping for VBA code that I can put into a command button's OnClick event.

Ebay has provided the following instructions:

1.  To upload your file programmatically, send an HTTP Post request to the File Exchange
server to accept.

2. Initiate an HTTPS connection then post your data file with your token to the File Exchange URL: https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeUpload.

See Sample HTTP Post Request:


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"
myTokenWillGoHere
--THIS_STRING_SEPARATES
Content-Disposition: form-data; name="file";
filename="MyFileName.csv"
Content-Type: text/csv
contents of listing.csv ...
 --THIS_STRING-SEPARATES
Comment
Watch Question

Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Jim Dettman (EE MVE)President / Owner
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2017
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
I guess I didn't understand how much I don't understand!  I have to use XML?
 
I was thinking I would create an HTML document .. Save it to disk.. And then somehow submit!?

I didn't understand either reply.
Jim Dettman (EE MVE)President / Owner
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2017

Commented:
Well in the example I posted, there was no XML involved.   I was simply sending a string to a web site, and getting string in return.   I used the XML library because it had the methods to send/receive from a web site, but there was no XML involved.  In the SOAP examples that Scott posted, there was.

Like anything, there are various ways to talk to a web site.   But basically, it's a stream of string data.  Of course what's in the string is where the difference come in.
 
From what you posted, it looks to me like you just need the POST and GET methods of HTTP and I would try to use the example I gave and see if it works.  If you look closely, you'll see that all I did was send a string:

            objRequest.Open "POST", strPostURL, False
            objRequest.Send strPostSting

 after opening a connection to a URL, and got a string in response:

           strPostResponse = objRequest.responseText

 Jim.
Scott McDaniel (EE MVE )Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
From what I can see of your requirements, the code Jim posted should do what you need - providing, of course, that your  Text file is properly formed. If your sample text is what EBay expects to get, then you'd simply modify Jim's post to create that text string, and send it to the URL you included in your original post.

FWIW - it's much, much easier to do this in .NET, since that can interact directly with the web service. If you're at all comfortable with .NET I'd suggest you consider creating a DLL in .NET that you can call from Access, and then use that ...

Author

Commented:
Ok..this is starting to make sense...no Scott, I've steered clear of .net until this point.
At my age, by the time I learn .net it I probably won't have enough years left to use it... Perhaps that why I'm still using Access 2k!

Jim, your code makes much more sense now.. I will try it as soon as I get my eBay token... A few questions though...

I already have a reference to Microsoft XML 2.0 lib, so I must have added that for some routine at one time.  Would you replace 2.0 w/ 6.0 and cross your fingers?

Does it look to you like the cvs file should be embedded in the string, or would you think just the path to the file is what they want?

The eBay code uses double quotes. Would you change them to single quotes or use the chr(34) character?
Jim Dettman (EE MVE)President / Owner
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2017

Commented:
<<I already have a reference to Microsoft XML 2.0 lib, so I must have added that for some routine at one time.  Would you replace 2.0 w/ 6.0 and cross your fingers?>>

  Yes on the first, no on the last.   First, do a compile of your existing project.  Make sure there are no errors.   Then remove the 2.0 reference.   Again compile.   No Errors?  Then your set...nothing in the existing project relies on that.

  If you do get errors, now set the reference to version 6.  Compile again...no errors?  You *may* be set.  You'll need to test the existing code to see if it works the same.  If errors, then something has changed between ver 2 and 6.

  With all that said, I don't know that the code I posted will not work with ver 2.0, but I would use 6.  2.0 must be quite old by this point.

<<Does it look to you like the cvs file should be embedded in the string, or would you think just the path to the file is what they want?>>

 Looks to me like they want the contents of the file in the string, but I didn't look at the docs, just the code you posted in the question.

Jim.
Martin LissSocial distance - Don't touch your face - Wash your hands for 20 seconds
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
Jim Dettman (EE MVE)President / Owner
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2017

Commented:
Scott was first to the plate with a correct answer and I was a close second.

Jim.
Scott McDaniel (EE MVE )Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
Agreed - accept my first comment and Jim's first comment as the solution.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.