• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1638
  • Last Modified:

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

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
0
pcalabria
Asked:
pcalabria
  • 4
  • 3
  • 2
  • +1
2 Solutions
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
VBA can use the SOAP methods for this. Here's a good example:

http://www.experts-exchange.com/Database/MS_Access/Q_22888194.html

Basically, you create the "request" string in the format expected by the web service, and then you "Post" that string to the webservice.

More specifically, the Expert provided a working example in this comment:

http://www.experts-exchange.com/Database/MS_Access/Q_22888194.html#a20074895

Note the use of XML in that question. You don't need to worry with that part, since your webservice expects a "text/scv" file format.
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
I don't understand all the various methods you can use to talk to a web site, but here's all that I did:

          ' Capture the CC

            ' Set the correct URL
            'strPostURL = "https://test.authorize.net/gateway/transact.dll"
            strPostURL = "https://secure.authorize.net/gateway/transact.dll"
            'strPostURL = "https://developer.authorize.net/tools/paramdump/index.php"

            strPostSting = ""
            strPostSting = strPostSting & "x_login=" & URLEncode(strAPILogin) & "&"
            strPostSting = strPostSting & "x_tran_key=" & URLEncode(strTransactionKey) & "&"
            'For debugging.
            'strPostSting = strPostSting & "x_test_request=" & URLEncode("TRUE") & "&"
            strPostSting = strPostSting & "x_version=" & URLEncode("3.1") & "&"
            strPostSting = strPostSting & "x_delim_data=" & URLEncode("TRUE") & "&"
            strPostSting = strPostSting & "x_delim_char=" & URLEncode("|") & "&"
            strPostSting = strPostSting & "x_relay_response=" & URLEncode("FALSE") & "&"
            strPostSting = strPostSting & "x_email_customer=" & URLEncode("FALSE") & "&"

            strPostSting = strPostSting & "x_type=" & URLEncode("PRIOR_AUTH_CAPTURE") & "&"
            strPostSting = strPostSting & "x_trans_id=" & URLEncode(rs!CCTransactionID) & "&"

            ' Additional fields can be added here as outlined in the AIM integration
            ' guide at: http://developer.authorize.net
            strPostSting = left(strPostSting, Len(strPostSting) - 1)

            ' We use xmlHTTP to submit the input values and record the response
            Dim objRequest As New MSXML2.XMLHTTP
            objRequest.Open "POST", strPostURL, False
            objRequest.Send strPostSting
            strPostResponse = objRequest.responseText
            'Debug.Print strPostResponse
            Set objRequest = Nothing

            ' the response string is broken into an array using the specified delimiting character
            arrResponse = Split(strPostResponse, "|", -1)

            If arrResponse(0) = 1 Then

 this required a reference to the Microsoft XML 6.0 lib.

Jim.
0
 
pcalabriaAuthor 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.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
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.
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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 ...
0
 
pcalabriaAuthor 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?
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
<<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.
0
 
Martin LissRetired ProgrammerCommented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
Scott was first to the plate with a correct answer and I was a close second.

Jim.
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Agreed - accept my first comment and Jim's first comment as the solution.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now