asked on
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
-----------START-----------
POST https://storage.sandbox.ebay.com/FileTransferService
Accept-Encoding: gzip, deflate
X-EBAY-SOA-OPERATION-NAME: uploadFile
Accept: */*
X-EBAY-SOA-SERVICE-VERSION: 1.1.0
X-EBAY-SOA-SERVICE-NAME: FileTransferService
Content-Length: 3936
Connection: keep-alive
Content-Type: multipart/related; boundary=MIME_boundary; type="application/xop+xml"; start="<0.urn:uuid:b2e95d5c-54ed-46ad-b479-fed744f2b8ca>"; start-info="text/xml"
User-Agent: python-requests/2.5.1 CPython/3.3.4 Darwin/14.0.0
X-EBAY-SOA-SECURITY-TOKEN: **MYSANDBOXTOKEN**
--MIME_boundary
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml; charset=UTF-8"
Content-Transfer_Encoding: binary
Content-ID: <0.urn:uuid:b2e95d5c-54ed-46ad-b479-fed744f2b8ca>
<uploadFileRequest xmlns:sct="http://www.ebay.com/soaframework/common/types" xmlns="http://www.ebay.com/marketplace/services">
<taskReferenceId>50008909051</taskReferenceId>
<fileReferenceId>50009059491</fileReferenceId>
<fileFormat>gzip</fileFormat>
<fileAttachment>
<Size>3121</Size>
<Data><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:urn:uuid:034d5afc-e1ac-4158-afab-8aae07e1423c"/></Data>
</fileAttachment>
</uploadFileRequest>
--MIME_boundary
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
Content-ID: <urn:uuid:034d5afc-e1ac-4158-afab-8aae07e1423c>
H4sIALnxy1QC/60YaXPixvL7/go9f8l7S9biFmxpVU9c5gZzm1QqNWgGaUAH1owA+denR+IQttkkVdkqLzN9X9 **... MORE ENCODED DATA ....** PZ/vc0wdv/LK3Rj3bRphsdvlxJT+c58l0olS58V7G1JiQXaioJin7Iu/frHXwTk+//fvgnOnxkwFsUAAA=
--MIME_boundary--
ASKER
ASKER
<?xml version="1.0" encoding="UTF-8"?>
<BulkDataExchangeRequests xmlns="urn:ebay:apis:eBLBaseComponents">
<Header>
<Version>967</Version>
<SiteID>0</SiteID>
</Header>
<AddFixedPriceItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<ErrorLanguage>en_US</ErrorLanguage>
<WarningLevel>High</WarningLevel>
<Version>967</Version>
<Item>
<CategoryMappingAllowed>true</CategoryMappingAllowed>
<Country>US</Country>
<Currency>USD</Currency>
<Description>Minimal fixed-price shoe listing with SKU, free shipping, 3-day dispatch time, return policy, and no Item Specifics. New Nike Shox Elite TB White/White-Black-Chrome. Size: Mens US 12, UK 11, Europe 46 (Medium, D, M). Condition: New in box.</Description>
<DispatchTimeMax>3</DispatchTimeMax>
<InventoryTrackingMethod>SKU</InventoryTrackingMethod>
<ListingDuration>Days_30</ListingDuration>
<ListingType>FixedPriceItem</ListingType>
<Location>San Jose, CA</Location>
<PaymentMethods>PayPal</PaymentMethods>
<PayPalEmailAddress>MegaOnlineMerchant@gmail.com</PayPalEmailAddress>
<PrimaryCategory>
<CategoryID>63850</CategoryID>
</PrimaryCategory>
<Quantity>6</Quantity>
<ReturnPolicy>
<ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>
<RefundOption>MoneyBack</RefundOption>
<ReturnsWithinOption>Days_30</ReturnsWithinOption>
<Description>Text description of return policy details here.</Description>
<ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption>
</ReturnPolicy>
<ShippingDetails>
<ShippingType>Flat</ShippingType>
<ShippingServiceOptions>
<ShippingServicePriority>1</ShippingServicePriority>
<ShippingService>USPSPriority</ShippingService>
<ShippingServiceCost currencyID="USD">0.0</ShippingServiceCost>
<ShippingServiceAdditionalCost>0.00</ShippingServiceAdditionalCost>
<FreeShipping>true</FreeShipping>
</ShippingServiceOptions>
</ShippingDetails>
<Site>US</Site>
<SKU>1122334455-14</SKU>
<StartPrice>50.00</StartPrice>
<Title>New Nike Shox Elite TB White Mens Basketball Shoes S 12</Title>
<UUID>7d004a30b0f511ddad8b0807654c9a56</UUID>
</Item>
</AddFixedPriceItemRequest>
<AddFixedPriceItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<ErrorLanguage>en_US</ErrorLanguage>
<WarningLevel>High</WarningLevel>
<Version>967</Version>
<Item>
<CategoryMappingAllowed>true</CategoryMappingAllowed>
<Country>US</Country>
<Currency>USD</Currency>
<Description>Minimal fixed-price shoe listing with SKU, free shipping, 3-day dispatch time, return policy, and no Item Specifics. New Nike Shox Elite TB BLACK / WHITE-VARSITY RED. Size: Mens US 12, UK 11, Europe 46 (Medium, D, M). Condition: New in box.</Description>
<DispatchTimeMax>3</DispatchTimeMax>
<InventoryTrackingMethod>SKU</InventoryTrackingMethod>
<ListingDuration>Days_30</ListingDuration>
<ListingType>FixedPriceItem</ListingType>
<Location>San Jose, CA</Location>
<PaymentMethods>PayPal</PaymentMethods>
<PayPalEmailAddress>MegaOnlineMerchant@gmail.com</PayPalEmailAddress>
<PrimaryCategory>
<CategoryID>63850</CategoryID>
</PrimaryCategory>
<Quantity>6</Quantity>
<ReturnPolicy>
<ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>
<RefundOption>MoneyBack</RefundOption>
<ReturnsWithinOption>Days_30</ReturnsWithinOption>
<Description>Text description of return policy details here.</Description>
<ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption>
</ReturnPolicy>
<ShippingDetails>
<ShippingType>Flat</ShippingType>
<ShippingServiceOptions>
<ShippingServicePriority>1</ShippingServicePriority>
<ShippingService>USPSPriority</ShippingService>
<ShippingServiceCost currencyID="USD">0.0</ShippingServiceCost>
<ShippingServiceAdditionalCost>0.00</ShippingServiceAdditionalCost>
<FreeShipping>true</FreeShipping>
</ShippingServiceOptions>
</ShippingDetails>
<Site>US</Site>
<SKU>1122334455-15</SKU>
<StartPrice>55.00</StartPrice>
<Title>New Nike Shox Elite TB Black Mens Basketball Shoes S 12</Title>
<UUID>7d005a30b0f511ddad8b0876540c9a57</UUID>
</Item>
</AddFixedPriceItemRequest>
</BulkDataExchangeRequests>
<?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:7d005a30b0f511ddad8b0876540c9a55"/></Data>
<Size>15</Size>
</fileAttachment>
<fileFormat>gzip</fileFormat>
<fileReferenceId>50047856</fileReferenceId>
<taskReferenceId>50012766</taskReferenceId>
</uploadFileRequest>
ASKER
ASKER
ASKER
I thank you Jim and please don't take this question in that way.
The main request here is just to show the proper way to set up a multi part / related MIME.......
Which I have found out there is not very much info online about how to do this in VBA.
ASKER
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.
TRUSTED BY