Link to home
Start Free TrialLog in
Avatar of Dustin Stanley
Dustin Stanley

asked on

HELP! MS Access VBA How Do you Add Attachments To XML Files Before Sending Over HTTP As API Call

This part is like banging your head against the wall!!!

It just don't make sense!

I have an XML file called uploadFile:

<?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>

Open in new window


I also have another XML file called Test14 that I gZipped up.  As I understand it  I have to attach Test14 within uploadFile where it says FileAttachment <Data> with a Cid UUID (I may be completely wrong. This may not be how VBA works) but that is what I understand.

API Call uploadFile Specs: https://developer.ebay.com/DevZone/file-transfer/CallRef/uploadFile.html

I am able to send the call with just uploadFile XML file but the attachment isn't there so it keeps returning an error of invalid Attachment.

Here is my HTTP Code:
Option Compare Database
Option Explicit

Public Function EbaySenderXmlAddFixedPriceItems()
Dim reader As New MSXML2.XMLHTTP40
    Dim doc As New MSXML2.DOMDocument 'If you want to load the XML Document instead of creating it.
    Dim TokenValue As String
    Dim APICALL As String
    
    '*************************************************************************************************************
    'API Call Name!
    '*************************************************************************************************************
      APICALL = "uploadFile" 'Place the API Call Name here within the parenthesis.
    '*************************************************************************************************************
    'Place Token Value Here Below!
    TokenValue = "TOKEN GOES HERE Like ujhuhuaeuyaeyayuo8i"
    '*************************************************************************************************************
    doc.Load "C:\Users\Station\Documents\Access XML Save Files\uploadFile.xml" 'Document Location of the XML File With Items Being Added
   
   
    '*************************************************************************************************************
    'Set The Headers Up!
    '*************************************************************************************************************
    reader.Open "POST", "https://storage.sandbox.ebay.com/FileTransferService", False
    reader.setRequestHeader "Content-ID", "<0.urn.uuid:FileAttachment UUID Here>" 'Must include FileAttachment UUID that matches the FileAttachment UUID!
    reader.setRequestHeader "X-EBAY-SOA-OPERATION-NAME", APICALL 'API Call Name
    reader.setRequestHeader "X-EBAY-SOA-SECURITY-TOKEN", TokenValue ' This is your Highly Secret Token. Place the Token above in the code where it says "Place Token Value Here!".
    reader.setRequestHeader "X-EBAY-SOA-SERVICE-VERSION", "1.5.0" 'Usually never have to change this unless if there is an update.
    reader.setRequestHeader "X-EBAY-API-SITEID", "0" ' 0 is for the USA Site!
    reader.setRequestHeader "X-EBAY-API-DEV-NAME", "Dev Name Here" 'Developers Name Code.
    reader.setRequestHeader "X-EBAY-API-APP-NAME", "App Name Here" 'Applications Name Code.
    reader.setRequestHeader "X-EBAY-API-CERT-NAME", "Certificate Name Here" 'Certificate Name Code.
    
    '*************************************************************************************************************
    'Use The Code After The Example Below To Build The XML File Instead Of Loading An Already Existing One!
    '*************************************************************************************************************
    'Expected OutPut Example!
    '**************************
    
    '<?xml version="1.0" encoding="UTF-8"?>
'<uploadFileRequest xmlns="http://www.ebay.com/marketplace/services">
  '<!-- Call-specific Input Fields -->
  '<fileAttachment> FileAttachment
    '<Data><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:urn:uuid:FileAttachment UUID Here"/></Data>
    '<Size>15</Size>
  '</fileAttachment>
  '<fileFormat>gzip</fileFormat>
  '<fileReferenceId>FILE REFRENCE ID HERE</fileReferenceId>
  '<taskReferenceId>JOB ID HERE</taskReferenceId>
'</uploadFileRequest>
'*************************************************************************************************************
    'Dim uploadFile As String 'If you want to create the XML Document instead of loading it.
   
    
    'uploadFile = ""
    'uploadFile = uploadFile & "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbNewLine
    'uploadFile = uploadFile & "<fileAttachment>" & vbNewLine
    'uploadFile = uploadFile & "<Data><xop:Include xmlns:xop=""http://www.w3.org/2004/08/xop/include"" href=""cid:urn:uuid:9eda0520-1a27-11e7-93ae-92361f002671""/></Data>" & vbNewLine
    'uploadFile = uploadFile & "<Size>15</Size>"
    'uploadFile = uploadFile & "<fileFormat>gzip</fileFormat>" & vbNewLine
    'uploadFile = uploadFile & "<fileReferenceId>50015247856</fileReferenceId>" & vbNewLine
    'uploadFile = uploadFile & "<taskReferenceId>50012765386</taskReferenceId>" & vbNewLine
    'uploadFile = uploadFile & "</uploadFileRequest>"
    
       'MsgBox uploadFile 'Shows MessageBox of the created XML file above.
         'reader.send uploadFile 'This sends the XML document from above that was created.

    '*************************************************************************************************************
    
    reader.send doc 'This sends the XML document from above that was loaded.
    
    
Do Until reader.ReadyState = 4
        DoEvents
    Loop
    
    MsgBox (reader.responseText) 'Shows MessageBox of the Servers Response. ie...Success or Error!
    
    If reader.Status = 200 Then
        Set doc = reader.responseXML
        doc.Save "C:\Users\Station\Documents\Access XML Save Files\New Testing\eBayReturnFile.xml" 'This is the return response from ebay after the document is sent and they process it.
         'MsgBox "PERFECT JUST LIKE YOU :)"
        
        Application.ImportXML "C:\Users\Station\Documents\Access XML Save Files\New Testing\eBayReturnFile.xml", acStructureAndData
        
    Else
        MsgBox "Error " & Err.Number & ": " & Err.Description & " in " & _
   VBE.ActiveCodePane.CodeModule, vbOKOnly, "Error"
    End If
    Set reader = Nothing
End Function

Open in new window


Also the gZip is in binary64 format if that helps with info.

Maybe they just both have to be sent together but either way I have no idea on how to accomplish this.

Please help and I thank you very much for any help I get!

Thanks!
Avatar of zc2
zc2
Flag of United States of America image

uploadFile.xml should contain the file you are uploading in base64 format.
Here is a link to a page containing a VB sample which encodes data to base64
http://www.motobit.com/tips/detpg_Base64Encode/

What did you mean by "Cid UUID" ?
Avatar of Dustin Stanley
Dustin Stanley

ASKER

Here is a link to a page containing a VB sample
I thank you but i have been working with that exact file for hours today. The gzipped file Test 14 is already in binary64. I had ran some code on it to encode it.

What did you mean by "Cid UUID" ?

Here is the exact uploadFile in XML I am using. If you look at the Tag <Data> you will see a Cid UUID code which I have that is Supposed to make my FileAttachment's UUID.....

**(I named the file I am using after the call name to make it less confusing on me)**

Basically what I am getting from this is I have the XML uploadFile and in that uploadFile the internal XML is saying "Hey I am wanting to make a uploadFile API Call and I have a fileAttachment with this UUID code."

The Server says ok and finds that combined gZipped file call Test14 with the same UUID code.
uploadFile I am sending to the API uploadFile:
<?xml version="1.0" encoding="UTF-8"?>
<uploadFileRequest xmlns="http://www.ebay.com/marketplace/services">
  <!-- Call-specific Input Fields -->
  <fileAttachment>
    <Data><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:urn:uuid:9eda0520-1a27-11e7-93ae-92361f002671"/></Data>
    <Size>15</Size>
  </fileAttachment>
  <fileFormat>gzip</fileFormat>
  <fileReferenceId>50047856</fileReferenceId>
  <taskReferenceId>5001386</taskReferenceId>
</uploadFileRequest>

Open in new window


***I bolded it for you below.****

<?xml version="1.0" encoding="UTF-8"?>
<uploadFileRequest xmlns="http://www.ebay.com/marketplace/services">
  <!-- Call-specific Input Fields -->
  <fileAttachment>
    <Data><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:urn:uuid:9eda0520-1a27-11e7-93ae-92361f002671"/></Data>
    <Size>15</Size>
  </fileAttachment>
  <fileFormat>gzip</fileFormat>
  <fileReferenceId>50047856</fileReferenceId>
  <taskReferenceId>5001386</taskReferenceId>
</uploadFileRequest>


So here is where I am needing help understanding this.  Some how I have to send both files at the exact same time (uploadFile.xml and Test14.gz)

I Don't understand how to put Test14.gz into uploadFile.xml.


I know it is very confusing. Thanks for the help.
In the EBay API manual page you mentioned I did not find any reference that the <Data> element's content should be <xop:Include> with a link to a separate resource. I believe, the base64 text content should be right there, the text content of the <Data>, like:
<?xml version="1.0" encoding="UTF-8"?>
<uploadFileRequest xmlns="http://www.ebay.com/marketplace/services">
  <!-- Call-specific Input Fields -->
  <fileAttachment>
    <Data>
WW91ciBUZXN0MTQuZ3ogZmlsZSBjb250ZW50LiBZb3VyIFRlc3QxNC5neiBmaWxlIGNvbnRlbnQu
IFlvdXIgVGVzdDE0Lmd6IGZpbGUgY29udGVudC4gWW91ciBUZXN0MTQuZ3ogZmlsZSBjb250ZW50
LiBZb3VyIFRlc3QxNC5neiBmaWxlIGNvbnRlbnQuIFlvdXIgVGVzdDE0Lmd6IGZpbGUgY29udGVu
dC4gWW91ciBUZXN0MTQuZ3ogZmlsZSBjb250ZW50LiBZb3VyIFRlc3QxNC5neiBmaWxlIGNvbnRl
bnQuIFlvdXIgVGVzdDE0Lmd6IGZpbGUgY29udGVudC4gWW91ciBUZXN0MTQuZ3ogZmlsZSBjb250
ZW50LiBZb3VyIFRlc3QxNC5neiBmaWxlIGNvbnRlbnQuIFlvdXIgVGVzdDE0Lmd6IGZpbGUgY29u
dGVudC4gWW91ciBUZXN0MTQuZ3ogZmlsZSBjb250ZW50LiBZb3VyIFRlc3QxNC5neiBmaWxlIGNv
bnRlbnQuIFlvdXIgVGVzdDE0Lmd6IGZpbGUgY29udGVudC4gWW91ciBUZXN0MTQuZ3ogZmlsZSBj
b250ZW50LiBZb3VyIFRlc3QxNC5neiBmaWxlIGNvbnRlbnQuIFlvdXIgVGVzdDE0Lmd6IGZpbGUg
Y29udGVudC4gWW91ciBUZXN0MTQuZ3ogZmlsZSBjb250ZW50LiBZb3VyIFRlc3QxNC5neiBmaWxl
IGNvbnRlbnQuIFlvdXIgVGVzdDE0Lmd6IGZpbGUgY29udGVudC4gWW91ciBUZXN0MTQuZ3ogZmls
ZSBjb250ZW50LiBZb3VyIFRlc3QxNC5neiBmaWxlIGNvbnRlbnQuIAo=
   </Data>
    <Size>673</Size>
  </fileAttachment>
  <fileFormat>gzip</fileFormat>
  <fileReferenceId>50047856</fileReferenceId>
  <taskReferenceId>5001386</taskReferenceId>
</uploadFileRequest>

Open in new window


I believe, the Size element should content the size of the file before it was base64 encoded.
I thank you very much for this and I will try that now. If you would like and I would REALLY appreciate it. I can give you a few links to look over. Again thank you so much. I have been going crazy.

Here is a slap together tutorial and one of the few if not only one online. He is using Python or something else I believe Not VBA like myself. This is a quick read of 5 minutes Step 10 of the second part.
https://medium.com/on-coding/dont-write-your-api-this-way-a1b745078b94

Here is the Large Merchants Services User Guide. This is a large page but what I am wanting you to look at is Example File Transfer Call about half way down. (Also not in VBA) There is some code of a sample that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<uploadFileRequest xmlns="http://www.ebay.com/marketplace/services">
  <taskReferenceId>5000003614</taskReferenceId>
  <fileReferenceId>5000028204</fileReferenceId>
  <fileFormat>gzip</fileFormat>
  <fileAttachment>
    <Data>
      <xop:Include href="cid:1.urn:uuid:FFAFEBBA9E369E19151224106591198@apache.org"
      xmlns:xop="http://www.w3.org/2004/08/xop/include"/>
    </Data>
  </fileAttachment>
</uploadFileRequest>

Open in new window


Link:https://developer.ebay.com/DevZone/large-merchant-services/Concepts/LMS_APIGuide.html

This API I guess is a VERY difficult one and this is the first one I started with ever.

Seriously thanks for the help!
When I do that it says invalid characters found in the XML.
ASKER CERTIFIED SOLUTION
Avatar of zc2
zc2
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you. See there is little parts here and there I just don't get. Thats lack of experience mainly.

In all the examples online they are in Python, PHP, C#, C++, Etc...... No VBA.

I only know VBA and that is just from the experts here.  This is a major part in my business that I have to learn.

But anyways all the samples in other Languages show these "multipart/related HTTP request" seperated by  --MIME_boundary. I am unsure how this has to happen in my VBA module above. There is just a single area for headers.

Its like i have 90% of the puzzle done but there is just a few pieces Missing???

1. How to properly attach the zip file to the XML file for the uploadFile call.
2. How to properly (in VBA) seperate my headers and file contents with  --MIME_boundary.

You stated:
carefully manage the CR and LF characters

I don't know if this is exactly what you are talking about but I can leave the XML in a solid string. I just did this for apperence for us now.  There is a 20,000 character limit per string. So that will cut them down.

Thanks for the help. I can't continue on until I get this.
-     carefully manage the CR and LF characters
I don't know if this is exactly what you are talking about but I can leave the XML in a solid string.
I meant between header and body, also between body parts. XML could be a single line, nobody cares.

You declare the boundary in the header, like:
reader.setRequestHeader "Content-Type", "multipart/related; boundary=some_random_string; type="application/xop+xml";
start="<0.urn:uuid:id_of_the_first_body_part>"; start-info="text/xml"

Then, when you form the body of your request, you separate the parts with
--some_random_string

Attached is an old VBscript class I once wrote which creates a multipart HTTP request. That's not exactly what you need, but I hope you could get some ideas .
post_.vbs
Thank you very much. I will see what I can come up with.

As a side note I don't know if your interested but I posted a gig yesterday.
https://www.experts-exchange.com/gigs/3222/Need-One-on-One-help-to-make-a-API-Call.html
Then, when you form the body of your request, you separate the parts with
--some_random_string

I think this is where I am getting most confused.


The way I see the code I have is the VBA does the headers and Loading/sending the file.  The file is already done. So in the VBA there is no "Body". I am probably wrong ???

 I have 2 options in my code above.
1. I can build the XML file with VBA. Line 52
2. I can load the XML into the VBA. Line 18

The body seems more plausable to me in option 1 but please let me know.

Where would I start the new "Body"???

Sorry for the lack of experience but we all have to start somewhere. I have a really bad habit of Going Big and not going home. So of course i started my adventure with one of the hardest ones available.

I really appreciate the help here. Thanks.
Body is the text parameter passed to the .Send() method. In a simple request it just a text or XML or JSON, whatever. In your case this text consists of a number (two) parts, each has its own header and separated by "--" & boundary_string.
The difference between the HTTP request header and a part's header that the HTTP header you forming using the methods of your request object (like you are already doing), but there are no helping methods to create the part's header, you should do that manually just by concatenating the strings or outputting to a stream.
passed to the .Send() method

I can only pass one file or the other to it. How do I pass both files so the .Send() method will send both files at the same time. Thanks.
I can only pass one file or the other to it.
That's not exactly correct. The method Send() accepts a variety of different types.
From the Send() method documentation:
optional parameter, which is the requestBody to use. The acceptable VARIANT input types are BSTR, SAFEARRAY of UI1 (unsigned bytes), IDispatch to an XML Document Object Model (DOM) object, and IStream *.
So, instead of passing to it a reference to XML DOM document (what you do) in
reader.send doc 'This sends the XML document from above that was loaded.
You should pass there a string or even better a stream with all your parts containing the XML and the attached file combined and separated by the specified in the HTTP header boundary.

Please look at the sample VB class I posted earlier. You can find there different request parts along with their headers and the boundary are written to a combining "ADODB.Stream" stream. Then the stream object reference is passed to the Send() method and all the parts are sent as a whole.
Here is my code I have so far:
Option Compare Database
Option Explicit
Private Sub CallFormUpload()
'*********************************
'Calls Formupload Function Below.
'*********************************
 Call FormUpload("C:\Users\Station\Documents\Access XML Save Files\New Testing\Test14.xml")
End Sub

Function FormUpload(strFileName As String) As String
    
    Dim WinHttpReq As WinHttp.WinHttpRequest
    Dim strBody As String
    Dim strFile As String
    Dim aPostBody() As Byte
    
    Dim bound As String
    Dim boundSeparator As String
    Dim boundFooter As String
    
    Dim strPostToURL As String
     strPostToURL = "https://storage.sandbox.ebay.com/FileTransferService"
    
    
    '**********************
    'Token Code Goes Here.
    '**********************
    Dim strMyToken As String
     strMyToken = "REPLACE THIS TEXT WITH YOUR TOKEN"
  
  '**********************
  'Define MIME Boundary
  '**********************
    bound = "123456789987654321"
    boundSeparator = "--" & bound & vbNewLine
    boundFooter = "--" & bound & "--"
    
    On Error GoTo ErrHandler1
    
    
    Set WinHttpReq = New WinHttpRequest
     WinHttpReq.Open "POST", strPostToURL, False
    
    '*************************************************************************************************************
    'API Call Name!
    '*************************************************************************************************************
     Dim APICALL As String
      APICALL = "uploadFile" 'Place the API Call Name here within the parenthesis.
      
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ' START OF HEADERS AND BODY!
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    '************************
    'Set Content-Type header
    '************************
    WinHttpReq.setRequestHeader "Content-Type", "multipart/form-data; boundary=" & bound
    WinHttpReq.setRequestHeader "Content-ID", "<0.urn.uuid:9eda06f61a2711e793ae92361f002671>" 'Must include NEW Request UUID!
    WinHttpReq.setRequestHeader "X-EBAY-SOA-OPERATION-NAME", APICALL 'API Call Name
    WinHttpReq.setRequestHeader "X-EBAY-SOA-SECURITY-TOKEN", strMyToken ' This is your Highly Secret Token. Place the Token above in the code where it says "Place Token Value Here!".
    WinHttpReq.setRequestHeader "X-EBAY-SOA-SERVICE-VERSION", "1.5.0" 'Usually never have to change this unless if there is an update.
    WinHttpReq.setRequestHeader "X-EBAY-API-SITEID", "0" ' 0 is for the USA Site!
    WinHttpReq.setRequestHeader "X-EBAY-API-DEV-NAME", "DEV NAME HERE" 'Developers Name Code.
    WinHttpReq.setRequestHeader "X-EBAY-API-APP-NAME", "APP NAME HERE" 'Applications Name Code.
    WinHttpReq.setRequestHeader "X-EBAY-API-CERT-NAME", "CERTIFICATE NAME HERE" 'Certificate Name Code.
    WinHttpReq.setRequestHeader "Content-Transfer_Encoding", "binary"
    WinHttpReq.setRequestHeader "Content-ID", "<0.urn.uuid:9eda06f61a2711e793ae92361f002671>" 'Must include NEW Request UUID (MUST MATCH ONE ABOVE)!
    
    '******************************************
    'Use strBody Below To Build The XML File!
    '******************************************
        Dim Attachment As String
        
         strFile = GetFile(strFileName)  ' Calls Function GetFile below to load up the AddFixedPriceItem File as a binary attachment.
    
    '***************
    'Request Header
    '***************
    strBody = vbNewLine & boundSeparator
    strBody = strBody & "Content-Type:text/xml" & vbNewLine
    strBody = strBody & "Content-Transfer_Encoding:binary" & vbNewLine
    strBody = strBody & "Content-ID:<0.urn.uuid:9eda06f61a2711e793ae92361f002671>" & vbNewLine & vbNewLine 'Must include Request UUID (MUST MATCH NEW ONE ABOVE)!
    
    '***************
    'uplaodFile XML
    '***************
    strBody = strBody & "<?xml version=""1.0"" encoding=""UTF-8""?><uploadFileRequest xmlns=""http://www.ebay.com/marketplace/services""><fileAttachment><Data><xop:Include xmlns:xop=""http://www.w3.org/2004/08/xop/include"" href=""cid:urn:uuid:9eda05201a2711e793ae92361f002671""/></Data><Size>15</Size></fileAttachment><fileFormat>gzip</fileFormat><fileReferenceId>50015256</fileReferenceId><taskReferenceId>50012766</taskReferenceId></uploadFileRequest>" & vbNewLine & vbNewLine

   '**********************
   'fileAttachment Header
   '**********************
    strBody = strBody & boundSeparator
    strBody = strBody & "Content-Type:text/xml" & vbNewLine
    strBody = strBody & "Content-Transfer_Encoding:binary" & vbNewLine
    strBody = strBody & "Content-ID:<0.urn.uuid:9eda05201a2711e793ae92361f002671>" & vbNewLine & vbNewLine 'Must include NEW Request UUID (MUST MATCH ONE ABOVE)!
   
    '**********************
    'Attachment File
    '**********************
    strBody = strBody & strFile & vbNewLine & boundFooter
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ' END OF HEADERS AND BODY!
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   
    '**********************
    'convert to byte array
    '**********************
    aPostBody = StrConv(strBody, vbFromUnicode)

    WinHttpReq.send aPostBody
    
    '***********************************
    'Message Box of Message From Server
    '***********************************
    MsgBox WinHttpReq.responseText, , "**eBaySays**"
    
    
    '***************************************
    'Writes Returned Message To a Text file.
    '***************************************
    Call SaveStringAsTextFile("C:\Users\Station\Documents\Access XML Save Files\New Testing\eBayReturnFile.xml", strBody)
    
    
    
    If WinHttpReq.Status = 200 Then
    
    '*********************************************
    'Writes Returned Error Message To a Text file.
    '*********************************************
         Call SaveStringAsTextFile("C:\Users\Station\Documents\Access XML Save Files\New Testing\ErroreBayReturnFile.xml", WinHttpReq.responseText)
        
    Else
ErrHandler1:
        MsgBox "Error " & Err.Number & ": " & Err.Description & " in " & _
   VBE.ActiveCodePane.CodeModule, vbOKOnly, "Error"
    End If
    Set WinHttpReq = Nothing
End Function

'*********************************************
'Returns file contents As a binary data
'*********************************************
Function GetFile(FileName)
  Dim Stream: Set Stream = CreateObject("ADODB.Stream")
  Stream.Type = 1 'Binary is value 1.
  Stream.Open
  Stream.LoadFromFile FileName
  GetFile = Stream.Read
  Stream.Close
End Function


Public Sub SaveStringAsTextFile(psPathFile As String, psFileContents)
'160730 strive4peace
   Dim iFile As Integer
   
   iFile = FreeFile
   Open psPathFile For Output As iFile
   Print #iFile, psFileContents
   Close iFile

End Sub

Open in new window


Can you give me any specifics on the spacing needed between the bodies and headers.

The XML file I am sending looks like this with my code:
--123456789987654321
Content-Type:text/xml
Content-Transfer_Encoding:binary
Content-ID:<0.urn.uuid:9eda06f61a2711e793ae92361f002671>

<?xml version="1.0" encoding="UTF-8"?><uploadFileRequest xmlns="http://www.ebay.com/marketplace/services"><fileAttachment><Data><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:urn:uuid:9eda05201a2711e793ae92361f002671"/></Data><Size>15</Size></fileAttachment><fileFormat>gzip</fileFormat><fileReferenceId>50015256</fileReferenceId><taskReferenceId>50012766</taskReferenceId></uploadFileRequest>

--123456789987654321
Content-Type:text/xml
Content-Transfer_Encoding:binary
Content-ID:<0.urn.uuid:9eda05201a2711e793ae92361f002671>

?????????•????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
--123456789987654321--

Open in new window


any input would be great and thank you for helping. All the ??????? is the binary file. I am using Notepad++
You've made a huge progress. The line spacing looks fine too. Make sure you add a correct Content-Length header with value of total size of your combined body.
Thank you. I added
lngLength = Len(strBody)

Open in new window


Is that supposed to included the binary file length also?

No matter what I do I keep getting error
<?xml version='1.0' encoding='UTF-8'?>
<errorMessage xmlns="http://www.ebay.com/marketplace/services">
<error><errorId>5006</errorId>
<domain>CoreRuntime</domain>
<severity>Error</severity>
<category>System</category>
<message>Unable to create xml stream reader for XML: payload format incorrect or payload is empty</message><subdomain>Comm_Recv</subdomain><parameter name="Param1">XML</parameter>
</error>
</errorMessage>
0

Open in new window


Also using Fiddler I get the same results.
Can you copy from Fiddler whole raw request data with the header and post it here? Remove only the binary bytes and sensitive info, like passwords.
I don't know if this is exactly what you want. I already had fiddler on my PC and I am no pro at all. I have just played with it a little. These requests were sent directly from the Fiddler application not my Access VBA. But:

POST https://storage.sandbox.ebay.com/FileTransferService HTTP/1.1
Content-Type: multipart/form-data; boundary=-------------------------acebdf13572468
User-Agent: Fiddler
Content-ID: <0.urn.uuid:9eda06f61a2711e793ae92361f002671>
User-Agent: Fiddler
X-EBAY-SOA-OPERATION-NAME: uploadFile
X-EBAY-SOA-SECURITY-TOKEN: TokenWasHere
X-EBAY-SOA-SERVICE-VERSION: 1.5.0
X-EBAY-API-SITEID: 0
X-EBAY-API-DEV-NAME: Dev Name Was Here
X-EBAY-API-APP-NAME: API Name Was Here
X-EBAY-API-CERT-NAME: Certificate Name Was Here
Host: storage.sandbox.ebay.com
Content-Length: 2756

---------------------------acebdf13572468
Content-Disposition: form-data; name="fieldNameHere"; filename="uploadFile.xml"
Content-Type: text/xml

<?xml version="1.0" encoding="UTF-8"?><uploadFileRequest xmlns="http://www.ebay.com/marketplace/services"><fileAttachment><Data><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:urn:uuid:9eda05201a2711e793ae92361f002671"/></Data><Size>15</Size></fileAttachment><fileFormat>gzip</fileFormat><fileReferenceId>50015246</fileReferenceId><taskReferenceId>50012386</taskReferenceId></uploadFileRequest>
---------------------------acebdf13572468
Content-Disposition: form-data; name="fieldNameHere"; filename="new2Zipped.gz"
Content-Type: application/x-gzip

  Binary was here!!!!!!!!!!!!!!!!!!!!!
---------------------------acebdf13572468--

Open in new window



Thank you for the help seriosly. It means a tons.
Also I don't know if this might help but here is the API release notes:
https://developer.ebay.com/DevZone/file-transfer/ReleaseNotes.html
In the manual you posted earler link to, there a sample request which has a header
Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_FFAFEBBA9E369E19151224106591181; type="application/xop+xml";
start="<0.urn:uuid:FFAFEBBA9E369E19151224106591182>"; start-info="tet/xml"

(i guess, there a type and it should be start-info="text/xml" )

But your request has a different Content-Type:
Content-Type: multipart/form-data; boundary=-------------------------acebdf13572468

In the previous comment you published the request body and each part has its own Content-ID in the header. But in the last one the parts do not have Content-ID headers.
Ok please bare with me. I did not know I had to input the extra content in the request body on fiddler.

This is what I have put directly into Fiddler

Header:

Content-Type: multipart/related; boundary=--MIMEBoundaryurn_uuid_FFAFEBBA9E369E19151224106591181; type="application/xop+xml";
start="<0.urn: uuid:9eda06f61a2711e793ae92361f002671>"; start-info="text/xml"
User-Agent: Fiddler
Content-ID: <0.urn.uuid:9eda06f61a2711e793ae92361f002671>
User-Agent: Fiddler
X-EBAY-SOA-OPERATION-NAME: uploadFile
X-EBAY-SOA-SECURITY-TOKEN: 
X-EBAY-SOA-SERVICE-VERSION: 1.1.0
X-EBAY-API-SITEID: 0
X-EBAY-API-DEV-NAME: 
X-EBAY-API-APP-NAME: 
X-EBAY-API-CERT-NAME: 
Host: storage.sandbox.ebay.com
Content-Length: 2985

Open in new window


Of coarse I removed sensitive info.

Request Body:
--MIMEBoundaryurn_uuid_FFAFEBBA9E369E19151224106591181
Content-Disposition: form-data; name="fieldNameHere"; filename="uploadFile.xml"
Content-Type: text/xml
Content-Transfer-Encoding: binary
Content-ID:<0.urn.uuid:9eda06f61a2711e793ae92361f002671>


<@INCLUDE *C:\Users\Station\Documents\Access XML Save Files\New Testing\uploadFile.xml*@>
--MIMEBoundaryurn_uuid_FFAFEBBA9E369E19151224106591181
Content-Disposition: form-data; name="fieldNameHere"; filename="new2Zipped.gz"
Content-Type: application/x-gzip
Content-Transfer-Encoding: binary
Content-ID:<0.urn.uuid:9eda05201a2711e793ae92361f002671>


<@INCLUDE *C:\Users\Station\Documents\Access XML Save Files\New Testing\new2Zipped.gz*@>
--MIMEBoundaryurn_uuid_FFAFEBBA9E369E19151224106591181--

Open in new window



Error now  raw says:
POST https://storage.sandbox.ebay.com/FileTransferService HTTP/1.1
Content-Type: multipart/related; boundary=--MIMEBoundaryurn_uuid_FFAFEBBA9E369E19151224106591181; type="application/xop+xml";
start="<0.urn: uuid:9eda06f61a2711e793ae92361f002671>"; start-info="text/xml"
User-Agent: Fiddler
Content-ID: <0.urn.uuid:9eda06f61a2711e793ae92361f002671>
User-Agent: Fiddler
X-EBAY-SOA-OPERATION-NAME: uploadFile
X-EBAY-SOA-SECURITY-TOKEN: 
X-EBAY-SOA-SERVICE-VERSION: 1.1.0
X-EBAY-API-SITEID: 0
X-EBAY-API-DEV-NAME: 
X-EBAY-API-APP-NAME: 
X-EBAY-API-CERT-NAME: 
Host: storage.sandbox.ebay.com
Content-Length: 2985

--MIMEBoundaryurn_uuid_FFAFEBBA9E369E19151224106591181
Content-Disposition: form-data; name="fieldNameHere"; filename="uploadFile.xml"
Content-Type: text/xml
Content-Transfer-Encoding: binary
Content-ID:<0.urn.uuid:9eda06f61a2711e793ae92361f002671>


<?xml version="1.0" encoding="UTF-8"?><uploadFileRequest xmlns="http://www.ebay.com/marketplace/services"><fileAttachment><Data><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:urn:uuid:9eda05201a2711e793ae92361f002671"/></Data><Size>15</Size></fileAttachment><fileFormat>gzip</fileFormat><fileReferenceId>50047856</fileReferenceId><taskReferenceId>50012386</taskReferenceId></uploadFileRequest>
--MIMEBoundaryurn_uuid_FFAFEBBA9E369E19151224106591181
Content-Disposition: form-data; name="fieldNameHere"; filename="new2Zipped.gz"
Content-Type: application/x-gzip
Content-Transfer-Encoding: binary
Content-ID:<0.urn.uuid:9eda05201a2711e793ae92361f002671>
BINARY HERE
--MIMEBoundaryurn_uuid_FFAFEBBA9E369E19151224106591181--

Open in new window


Textview Response:

<html><head><title>Apache Tomcat/5.5.15-150 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>javax.servlet.ServletException: Mime parts not found. Stream ended while searching for the boundary
	com.ebay.soaframework.spf.pipeline.SPFServlet.doPost(SPFServlet.java:179)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:615)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
</pre></p><p><b>root cause</b> <pre>org.apache.axiom.om.OMException: Mime parts not found. Stream ended while searching for the boundary
	org.apache.axiom.attachments.Attachments.&lt;init&gt;(Attachments.java:226)
	org.apache.axiom.attachments.Attachments.&lt;init&gt;(Attachments.java:255)
	com.ebay.soaframework.common.impl.attachment.InboundMessageAttachments.createAttachments(InboundMessageAttachments.java:69)
	com.ebay.soaframework.common.impl.attachment.BaseMessageAttachments.getAttachments(BaseMessageAttachments.java:26)
	com.ebay.soaframework.common.impl.attachment.BaseMessageAttachments.getInputStreamForMasterMessage(BaseMessageAttachments.java:44)
	com.ebay.soaframework.common.impl.internal.pipeline.InboundMessageImpl.setInputStream(InboundMessageImpl.java:482)
	com.ebay.soaframework.common.impl.internal.pipeline.InboundMessageImpl.setInputStream(InboundMessageImpl.java:421)
	com.ebay.soaframework.spf.pipeline.ServerMessageContextBuilder.createMessageContext(ServerMessageContextBuilder.java:719)
	com.ebay.soaframework.spf.pipeline.ServerMessageContextBuilder.setInputStream(ServerMessageContextBuilder.java:738)
	com.ebay.soaframework.spf.impl.transport.http.HTTPServerUtils.createMessageContext(HTTPServerUtils.java:232)
	com.ebay.soaframework.spf.pipeline.SPFServlet.doPost(SPFServlet.java:166)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:615)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/5.5.15-150 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/5.5.15-150</h3></body></html>

Open in new window



I truly believe if I can get this figured out just to go through with Fiddler then I can quickly figure the rest out.


THANK YOU!
I think that problem was the 2 "-" and i did not place the 4 "-" in the body.

I removed the 2 in the header and it is going back to the original error message of empty payload
The error message you posted says: Mime parts not found. Stream ended while searching for the boundary

The boundary string declared in header's Content-Type starts with two dashes, but actual boundaries between parts also have only two dahes, but they have to be two dashes Plus the string declared in Content-Type, so need 4 dashes total.
Yeah I seen that and I removed the two dashes. After that it went right back to original error message of empty payload. thank you for the help. I just left work and I won't be able to work on it until Monday. Thanks
I see a difference between your request and the sample, which has the following header in the XML part:
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"

But yours has just
Content-Type: text/xml
I tried both ways. There is just something not quite right. Hopefully soon I will be able to figure it out. Thanks
Ok this is what I have so far today. I contacted ebay and this is a VBA sample they sent me.

But once again as in all their documentation it does not follow the exact rules as other documents say. I am waiting on a response if I am lucky......

Origanl sent VBA:

  ReferenceID="yourReferenceID"
     JobID="yourJobID"
     UserToken="yourAuthToken"
     DataFile="ContentOfYourXMLFile"
     compatLevel="1.5.0"
     Verb="uploadFile"
     fileformat="zip"
     
     XMLcallAddress="/XML/eBay/XML/Large/"&Verb&".xml"
     DataZip=Base64Encode(DataFile)
     SizeZip=len(DataZip)
     set xmlRequestDoc = Server.CreateObject("MSXML2.DOMDocument")
     xmlRequestDoc.load(Server.MapPath(XMLCallAddress))
     xmlRequestdoc.selectSingleNode(Verb & "Request/fileAttachment/Data").nodeTypedValue=DataZip
     xmlRequestdoc.selectSingleNode(Verb & "Request/fileAttachment/Size").nodeTypedValue=SizeZip
     xmlRequestdoc.selectSingleNode(Verb & "Request/fileFormat").nodeTypedValue=FileFormat
     xmlRequestdoc.selectSingleNode(Verb & "Request/fileReferenceId").nodeTypedValue=ReferenceID
     xmlRequestdoc.selectSingleNode(Verb & "Request/taskReferenceId").nodeTypedValue=JobID
 
     'Send the Request and Get Response
     set xmlResponse = PostXmlRequestFT (xmlRequestDoc, verb, CompatLevel, UserToken)
 
     'Check Response exists
     if xmlResponse is nothing then
             Response.Write("Request could not be completed")    
         else
             'if response has error messages
             '........
             else
                 ' parse the response
             end if
     
         end if
     
     end if
 
 
     '*************************
     
     Function PostXmlRequestFT (xmlDoc, Verb, CompatLevel,Token)
             'Create a new ServerXMLHTTP object to post the request and get the response
             set xmlRequest = Server.CreateObject("MSXML2.ServerXMLHTTP")
             ServiceName="FileTransferService"
             'set method and server URL
             FT_URL="https://storage.ebay.com/FileTransferService"
             xmlRequest.open "POST", FT_URL
             
             'Set the required HTTP Headers for the request
             xmlRequest.setRequestHeader "Content-Type", "text/xml"
             'Regulates versioning of the XML interface for the API
             xmlRequest.setRequestHeader "X-EBAY-SOA-SECURITY-TOKEN", Token
             xmlRequest.setRequestHeader "X-EBAY-SOA-SERVICE-NAME", ServiceName
             xmlRequest.setRequestHeader "X-EBAY-SOA-SERVICE-VERSION", CompatLevel
             xmlRequest.setRequestHeader "X-EBAY-SOA-OPERATION-NAME", verb
             'send the request
             xmlRequest.send xmlDoc
             
             If xmlRequest.status = 200 then
                 set PostXmlRequestFT = xmlRequest.responseXML
             else
                 set PostXmlRequestFT = nothing
             End If
         End Function

Open in new window



I have altered it a little bit:

Option Compare Database
Option Explicit
Private Sub ebayForumVBA()
Dim ReferenceID, JobID, UserToken, CompatLevel, Verb, FileFormat, XMLcallAddress As String
Dim SizeZip As Integer
Dim DataZip As Variant

Dim xmlRequestDoc As New MSXML2.DOMDocument
Dim xmlResponse As New MSXML2.DOMDocument

     ReferenceID = "50015246" 'FILE REFRENCE ID GOES HERE (CHANGE AS NEEDED)
     JobID = "5001286" ' JOB ID GOES HERE (CHANGE AS NEEDED)
     UserToken = "YOUR TOKEN HERE" 'PLACE YOUR TOKEN HERE (CHANGE AS NEEDED)
     CompatLevel = "1.5.0"
     Verb = "uploadFile" 'API CALL NAME (CHANGE AS NEEDED)
     FileFormat = "gzip" ' "zip" or "gzip" allowed only in lowercase
     XMLcallAddress = "C:\Users\Station\Documents\Access XML Save Files\New Testing\" & Verb & ".xml" ' xml File Path of uploadFile
     DataZip = "C:\Users\Station\Documents\Access XML Save Files\New Testing\NewBulk1.xml" ' xml File Path of the file attachment such as AddFixedPriceItem
     SizeZip = Len(DataZip) ' THIS AUTO MAKES THE FILE SIZE FOR THE SIZE VALUE IN THE XML FILE.
     
     Set xmlRequestDoc = CreateObject("MSXML2.DOMDocument")
     
     xmlRequestDoc.Load (XMLcallAddress)
     xmlRequestDoc.SelectSingleNode(Verb & "Request/fileAttachment/Data").nodeTypedValue = DataZip 'DATA NODE VALUE
     xmlRequestDoc.SelectSingleNode(Verb & "Request/fileAttachment/Size").nodeTypedValue = SizeZip ' SIZE NODE VALUE
     xmlRequestDoc.SelectSingleNode(Verb & "Request/fileFormat").nodeTypedValue = FileFormat ' FILEFORMAT NODE VALUE
     xmlRequestDoc.SelectSingleNode(Verb & "Request/fileReferenceId").nodeTypedValue = ReferenceID ' FILE REFRENCE ID NODE VALUE
     xmlRequestDoc.SelectSingleNode(Verb & "Request/taskReferenceId").nodeTypedValue = JobID ' TASK REFRENCE ID NODE VALUE
 
     'Send the Request and Get Response
     Set xmlResponse = PostXmlRequestFT(xmlRequestDoc, Verb, CompatLevel, UserToken)
 
     'Check Response exists
     If xmlResponse Is Nothing Then
             MsgBox ("Request could not be completed")
         Else
         MsgBox ("Request was SOMETHING") ' just letting you know it was something....
         
         'if response has error messages
             '........
             'Else
                 ' parse the response
            ' End If
     
     End If
 End Sub
 
     '*************************
     
     Function PostXmlRequestFT(xmlDoc, Verb, CompatLevel, Token)
     
     Dim Server As New MSXML2.ServerXMLHTTP
     'Dim xmlRequest As New MSXML2.DOMDocument
     Dim xmlRequest As New MSXML2.XMLHTTP40
     Dim ServiceName, FT_URL As String
     Dim Doc As New MSXML2.DOMDocument
     
     
             'Create a new ServerXMLHTTP object to post the request and get the response
             Set xmlRequest = CreateObject("MSXML2.ServerXMLHTTP")
             ServiceName = "FileTransferService" ' the service we are using.
             'set method and server URL
             FT_URL = "https://storage.sandbox.ebay.com/FileTransferService" ' URL you are sending you POST to (Change for Sandbox or Production)
             xmlRequest.Open "POST", FT_URL
             
             'Set the required HTTP Headers for the request
             xmlRequest.setRequestHeader "Content-Type", "text/xml"
             'Regulates versioning of the XML interface for the API
             xmlRequest.setRequestHeader "X-EBAY-SOA-SECURITY-TOKEN", Token 'Change token above not here
             xmlRequest.setRequestHeader "X-EBAY-SOA-SERVICE-NAME", ServiceName
             xmlRequest.setRequestHeader "X-EBAY-SOA-SERVICE-VERSION", CompatLevel
             xmlRequest.setRequestHeader "X-EBAY-SOA-OPERATION-NAME", Verb ' Change Verb above. This is the API call name.
             xmlRequest.setRequestHeader "Content-ID", "<0.urn.uuid:9eda05201a2711e793ae92361f002671>" 'UUID that matches the request UUID.
        
             Set Doc = xmlDoc
                 Doc.Save "C:\Users\Station\Documents\Access XML Save Files\New Testing\eBayOriginalSend.xml" 'This is the return response from ebay after the document is sent and they process it.
                 
                 'send the request
             xmlRequest.send xmlDoc
             
             If xmlRequest.Status = 200 Then
                 Set PostXmlRequestFT = xmlRequest.responseXML
                 Set Doc = xmlRequest.responseXML
                 Doc.Save "C:\Users\Station\Documents\Access XML Save Files\New Testing\eBayStatusReturnFile7.xml" 'This is the return response from ebay after the document is sent and they process it.
                Else
                 
                 Set PostXmlRequestFT = Nothing
             End If
         End Function
        

Open in new window



There is supposed to be a UUID in the data node and a few other things that the VBA does not include. Hopefully they will respond with an answer soon.

I am now getting a error of invalid file format.

I have validated my XML files and they look good to me. eBay says use Base64 encoding but elsewhere has said it doesn't matter.

I get the same error 11 invalid file format either way. With fiddler it says error "Unable to create xml stream reader for XML: payload format incorrect or payload is empty".

I am wondering if in my VBA code if it is sending the file as a string and not a file (DataZip LINE: 18) of the bottom code box.  I am not good at "dimming" either so I am unsure if that is good.

I have tried sending gzip and xml files both same errors.

Thanks I will let you know what they say or I find out.
Apparently the VB they sent you is able to send only a single XML, with no attachment as in their HTTP sample we discussed earlier.
Did you try to execute a different type of API transaction which does not require  to send a file, just send some XML and get some result?
Can that be executed without errors?
Yes I was able to send an API of a single item without any problems through my VBA code (different then the one above because it is not setup for a single call) and also it went through perfect on fiddler.

Here is the single itm call. This call is AddFixedPriceItem and it will post a single item only.
Option Compare Database
Option Explicit

Public Function EbaySenderXmlAddFixedPriceItems()
Dim reader As New MSXML2.XMLHTTP40
    Dim Doc As New MSXML2.DOMDocument
    Dim TokenValue As String
    Dim APICALL As String
    
    TokenValue =  ' This is used for the Token Code insert manually on the Form Ebay Add Fixed Price Item.
    
    APICALL = "AddFixedPriceItem"
    
    Doc.Load "C:\Users\Station\Documents\Access XML Save Files\New Testing\777.xml" 'Document Location of the XML File With Items Being Added

   
    
    reader.Open "POST", "https://api.sandbox.ebay.com/ws/api.dll", False
    reader.setRequestHeader "X-EBAY-API-CALL-NAME", APICALL
    reader.setRequestHeader "X-EBAY-API-DETAIL-LEVEL", "0"
    reader.setRequestHeader "X-EBAY-API-COMPATIBILITY-LEVEL", "967"
    reader.setRequestHeader "X-EBAY-API-SITEID", "0"
    reader.setRequestHeader "X-EBAY-API-DEV-NAME", ""
    reader.setRequestHeader "X-EBAY-API-APP-NAME", ""
    reader.setRequestHeader "X-EBAY-API-CERT-NAME", ""
    reader.setRequestHeader "CONTENT-TYPE", "text/html"
    reader.setRequestHeader "X-EBAY-API-IAF-TOKEN", TokenValue
    

    reader.send Doc 'This sends the XML document from above.
    
Do Until reader.ReadyState = 4
        DoEvents
    Loop
    
    MsgBox (reader.responseText)
    
    If reader.Status = 200 Then
        Set Doc = reader.responseXML
        Doc.Save "C:\Users\Shipper Station\OneDrive\Database Testing\EbayDatabase\eBayReturnFile.xml" 'This is the return response from ebay after the document is sent and they process it.
        
        Application.ImportXML "C:\Users\Station\OneDrive\Database Testing\EbayDatabase\eBayReturnFile.xml", acStructureAndData
        
    Else
        MsgBox "Error " & Err.Number & ": " & Err.Description & " in " & _
   VBE.ActiveCodePane.CodeModule, vbOKOnly, "Error"
    End If
    Set reader = Nothing
End Function

Open in new window



Also the output the VBA they gave me gives you an XML file that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<uploadFileRequest xmlns="http://www.ebay.com/marketplace/services">
	<taskReferenceId>500127686</taskReferenceId>
	<fileReferenceId>500152456</fileReferenceId>
	<fileFormat>gzip</fileFormat>
	<fileAttachment>
		<Data>C:\Users\Station\Documents\Access XML Save Files\New Testing\IDKTest1.xml</Data>
		<Size>81</Size>
	</fileAttachment>
</uploadFileRequest>

Open in new window


I don't know if you have any experience with Base64 encoding but here is what I have. I used notepad++ and encoded the file:
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxCdWxrRGF0YUV4Y2hhbmdlUmVxdWVzdHMgeG1sbnM9InVybjplYmF5OmFwaXM6ZUJMQmFzZUNvbXBvbmVudHMiPg0KICA8SGVhZGVyPg0KICAgIDxWZXJzaW9uPjk2NzwvVmVyc2lvbj4NCiAgICA8U2l0ZUlEPjA8L1NpdGVJRD4NCiAgPC9IZWFkZXI+DQo8QWRkRml4ZWRQcmljZUl0ZW1SZXF1ZXN0IHhtbG5zPSJ1cm46ZWJheTphcGlzOmVCTEJhc2VDb21wb25lbnRzIj4NCiAgPEVycm9yTGFuZ3VhZ2U+ZW5fVVM8L0Vycm9yTGFuZ3VhZ2U+DQogIDxNZXNzYWdlSUQ+TWVzc2FnZUlEMTwvTWVzc2FnZUlEPg0KICA8VmVyc2lvbj45Njc8L1ZlcnNpb24+DQogIDxJdGVtPg0KICAgIDxDYXRlZ29yeU1hcHBpbmdBbGxvd2VkPnRydWU8L0NhdGVnb3J5TWFwcGluZ0FsbG93ZWQ+DQogICAgPENvdW50cnk+VVM8L0NvdW50cnk+DQogICAgPEN1cnJlbmN5PlVTRDwvQ3VycmVuY3k+DQogICAgPERlc2NyaXB0aW9uPkRlc2N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MDwvQ29uZGl0aW9uSUQ+DQogIDwvSXRlbT4NCjwvQWRkRml4ZWRQcmljZUl0ZW1SZXF1ZXN0Pg0KPC9CdWxrRGF0YUV4Y2hhbmdlUmVxdWVzdHM+

Open in new window



Can you decode it if you know how and everything come out good? Also does this fall under what ebay calls "The zipped report file that is encoded in Base64 Binary format and included in the request according to the SOAP MTOM standard."???


***UPDATE****
I think I have it set up mostly correct. It is now also saying invalid File Format:
Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_FFAFEBBA9E369E19151224106591181; type="text/xmll";
start="<0.urn: uuid:9eda06f61a2711e793ae92361f002671>"; start-info="text/xml"
User-Agent: Fiddler
User-Agent: Fiddler
X-EBAY-SOA-OPERATION-NAME: uploadFile
X-EBAY-SOA-SECURITY-TOKEN: TOKEN HERE
X-EBAY-SOA-SERVICE-VERSION: 1.1.0
X-EBAY-API-SITEID: 0
X-EBAY-API-DEV-NAME: DEV NAME HERE
X-EBAY-API-APP-NAME: API APP NAME HERE
X-EBAY-API-CERT-NAME: CERT NAME HERE
Host: storage.sandbox.ebay.com
Content-Length: 5021

Open in new window


--MIMEBoundaryurn_uuid_FFAFEBBA9E369E19151224106591181
Content-Disposition: form-data; name="fieldNameHere"; filename="uploadFile.xml"
Content-Type: text/xml
Content-ID:<0.urn.uuid:9eda06f61a2711e793ae92361f002671>

<@INCLUDE *C:\Users\Station\Documents\Access XML Save Files\New Testing\uploadFile.xml*@>
--MIMEBoundaryurn_uuid_FFAFEBBA9E369E19151224106591181
Content-Disposition: form-data; name="fieldNameHere"; filename="AddFixedFromEbay.xml"
Content-Type: text/xml
Content-ID:<0.urn.uuid:9eda05201a2711e793ae92361f002671>

<@INCLUDE *C:\Users\Station\Documents\Access XML Save Files\New Testing\AddFixedFromEbay.xml*@>
--MIMEBoundaryurn_uuid_FFAFEBBA9E369E19151224106591181--

Open in new window


At least I believe I am narrowing down the problem. Fiddler IS SENDING BOTH FILES! But it is also now saying invalid File Format just like when I send it from my VBA module.

Here is the KEY.....You have to have 3 UUIDs
1.XML UUID
2.Request UUID
3.fileAttachment UUID (Which matches the UUID inside the <Data> node in the uploadFile XML file.

1. XML UUID is found in the Header Code Line 1 and also in the Request Body Code Lines 1, 7, 13 (These all have to match)

2. Request UUID is found in the Header Code Line 2 and in the Request Body Code Line 4  (These all have to match)

3. fileAttachment UUID is found in the Request Body Code Line 10 and also inside the <Data> node in the uploadFile XML file.  (These all have to match)


They all may even have to start with "MIMEBoundaryurn_uuid_" I don't know.

Thanks.
I was able to decode your base64 to some XML.

Sorry, I am not familiar with SOAP MTOM. It's apparently described here but I did not study that.

You are correct about the IDs. An ID for the whole request, one for each part, and the upload XML refers to the attachment part by its ID.
I'm not sure is the format of that ID important. I believe it could be just any string, but only ebay staff can tell for sure.

I use Fiddler as a proxy, so you can check what exactly was sent to the server. Did you try that?
I use Fiddler as a proxy, so you can check what exactly was sent to the server. Did you try that?

I was actually just working on this. I have had "Success" FINALLY!!!! With Fiddler.  But there is something wrong within the file I sent.

Basically I have received a Success response  but I can't read the darn thing because it is zipped and most likely in base64 encoding.

I opened another question trying to get help with this part so I can see what it says. I believe it will be a small error and once I can fix them then everything should work great.
Question is here:
https://www.experts-exchange.com/questions/29015488/MS-Access-VBA-How-To-Decompress-a-Gzip-Response-From-a-HTTP-Request.html
I only can suggest to load the whole response to ADODB.Stream object and try to parse it line by line. Quite complex code would be for sure. May be somebody did implement that, try to search. I have a similar in C++, if that could help.
I am still working on this. Once i get an update I will post back. Thanks
Thank you!  So far I have not had any luck except with using ChillKat Software. But as far as for VBA nothing.
You are welcome. That's true, I should have suggest you to look at the Chilkat library. It is very robust an we use it in our projects too (but not the HTTP part)
I tried it out and then contacted the support team. I said " Hey if you walk me through this I will buy this quicker than a heartbeat". He has been very helpful beyond belief and he has added an example section just for ebay on their site. I know this will bring them new customers for sure.

https://www.example-code.com/vb6/ebay.asp

It is for sure worth the money spent without a doubt!