Dustin Stanley
asked on
How to send a gZip File From My PC to a Server through a URL From VBA in MS Access
IF I have a gZip file on my PC how would I send this file to a server through a URL. I know how to send XML but not a gZip file.
Here is part of my code to send the XML. Is it similiar?
Thanks.
Here is part of my code to send the XML. Is it similiar?
Dim reader As New MSXML2.XMLHTTP40
Dim doc As New MSXML2.DOMDocument
doc.Save "C:\Users\Station\Documents\Access XML Save Files\Test14Update.xml"
reader.Open "POST", "https://webservices.sandbox.ebay.com/BulkDataExchangeService", False
reader.send doc 'This sends the XML document from above.
Thanks.
ASKER
It is the same as the XML file. My problem is when I try with my XML module to send the gzip is says wrong end of file or something like that. I'm out of my office right now.
I assumed it was because access sees I am supposed to sending an xml with the Dim doc as MSXML2.
So what is the bare procedure for this. what would I dim the gzip file as instead of MSXML2.
what would I dim Reader as also?
Is it still reader.send doc????
thanks
I assumed it was because access sees I am supposed to sending an xml with the Dim doc as MSXML2.
So what is the bare procedure for this. what would I dim the gzip file as instead of MSXML2.
what would I dim Reader as also?
Is it still reader.send doc????
thanks
That depends on what the BulkDataExchangeService is expecting you to send. If it's expecting an XML feed, then you'd just send that (i.e. the Doc). In some cases you have to "read" the document to the feed.
But you must first determine exactly what that BulkDataExhcangeService is expecting. Generally a web service documents the calls you can make to it. Contact the owner/operator of the service to get that information.
But you must first determine exactly what that BulkDataExhcangeService is expecting. Generally a web service documents the calls you can make to it. Contact the owner/operator of the service to get that information.
ASKER
Thank you Scott for the help. I am glad you brought up
I honestly do not understand or know what that means "Read the GZIP file back in" .
I am very new at this part of sending a zip to the server. As I have had great success in sending direct XML to the API Server a single request at a time. But in order to send multiple requests of the same kind you have to gZip it up and upload the file with the API call "StartUploadJob".
I have found a website where they show some of the steps involved. They are using PHP Code examples but I am using XML. For the most part it is all the same in procedure.
https://medium.com/on-coding/dont-write-your-api-this-way-a1b745078b94https://medium.com/on-codi ng/dont-wr ite-your-a pi-this-wa y-a1b74507 8b94
Here is what is said:
Also for this the call I have to use is API call "uploadFile" and here is the link to them specs:
https://developer.ebay.com /DevZone/f ile-transf er/CallRef /uploadFil e.html
Expected:
fileAttachment (The zipped report file that is encoded in Base64 Binary format and included in the request according to the SOAP MTOM standard.)
Thanks Scott for the help!
In some cases you have to "read" the document to the feed.
I honestly do not understand or know what that means "Read the GZIP file back in" .
I am very new at this part of sending a zip to the server. As I have had great success in sending direct XML to the API Server a single request at a time. But in order to send multiple requests of the same kind you have to gZip it up and upload the file with the API call "StartUploadJob".
I have found a website where they show some of the steps involved. They are using PHP Code examples but I am using XML. For the most part it is all the same in procedure.
https://medium.com/on-coding/dont-write-your-api-this-way-a1b745078b94https://medium.com/on-codi
Here is what is said:
1. Use the above 1-9 steps to make a normal XML API call to “createUploadJob” passing it the type of job you want, and a UUID. You will get back a jobId and a fileId. This call is to the BulkDataExchangeService API.
2. Form an XML document that repeats the type of request you want as many times as you need it to be called. So for ReviseFixedPricedItem it would be <ReviseFixedPricedItemRequest> x 20 for 20 products.
3. Make sure to add the correct XMLNS to every single one of those 20 nodes.
4. Wrap that entire XML document in a <BulkDataExchangeRequests>node.
5. Before your massive array of repeated fields, add a <Header> node that contains the SiteID and API Version. This is instead of the Site and Version headers from the previous API calls.
6. Save the XML document to disk.
7. GZIP the XML document. (You can do step 6 and 7 together).
8. Read the GZIP file back in.
9. Create two new UUIDs, one for a request and one for an attachment.
10. Setup a SOAP 1.1 or 1.2 with MTOM encoding or XML over HTTP to include the file. This, I learned means you form your XML packet for the FileTransferAPI’s method of uploadFile to have a key called fileAttachment. This key has Size and Data. The Data key is a <xop:Include node which it’s own XMLNS:xop url and a cid:urn:uuid that matches the attachment UUID you created in step 9.
11. Create the earlier steps 1-9 XML style request for “uploadFile”
12. Instead of passing that XML like the old days, we now need to form a multi-part related request.
13. Create your first MIME part using the Content-Type of
Content-Type: application/xop+xml; charset=UTF-8; type=”text/xml;
14. Set the Content-ID part to something like <0.urn.uuid:123456 where 123456 matches the request UUID from step 9
15. Now dump your XML from step 11 with an ending MIME boundary
16. Create your second MIME section using and application/octet stream. This sections Content-ID should match the attachment UUID from step 9.
17. Before you end the last boundary, make sure to include your read in file data from step 8
18. Setup your headers for the request to have this complex Content-Type of multipart-related. Here you tell it what your boundary is, that the first type is xop+xml and your starting <0.urn:uuid that matches the request UUID from step 9.
19. Combine both sections from step 13 and 16 and send that request with the headers from step 18.
20. Make a normal 1-9 style XML API call to the BulkDataExchangeService API using the method “startUploadJob” to actually start the upload.
21. Later you can check on this with Bulk data services / getJobStatus
Also for this the call I have to use is API call "uploadFile" and here is the link to them specs:
https://developer.ebay.com
Expected:
<?xml version="1.0" encoding="utf-8"?>
<uploadFileRequest xmlns="http://www.ebay.com/marketplace/services">
<!-- Call-specific Input Fields -->
<fileAttachment> FileAttachment
<Data> base64Binary </Data>
<Size> long </Size>
</fileAttachment>
<fileFormat> token </fileFormat>
<fileReferenceId> string </fileReferenceId>
<taskReferenceId> string </taskReferenceId>
</uploadFileRequest>
fileAttachment (The zipped report file that is encoded in Base64 Binary format and included in the request according to the SOAP MTOM standard.)
Thanks Scott for the help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I thank you and yes that would be a HUGE request. But. in this question I was mainly concerned with the first part as in how to set up the gZip file sending in VBA.
I just wanted to let you know where this is going. Thanks.
I just wanted to let you know where this is going. Thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Scott for the help!
In the example above, the "BulkDataExchangeService" is the method you're sending that XML file to. There should be something similar that will accept your zip file.