Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) eBay -- Upload Bulk Data using FileTransferServiceDemonstrates how to upload your data file using the eBay File Transfer API.
Use ChilkatAx-win32.pkg Procedure Test String sAccessToken Handle hoHttp String sApiCall String sFileAttachmentUuid String sXmlUuid Variant vReq Handle hoReq Handle hoSbContentType Boolean iSuccess Integer iReplaceCount String sPathToFileOnDisk1 Boolean iSuccess String sPathToFileOnDisk2 Variant vResp Handle hoResp Handle hoXml String sTemp1 Integer iTemp1 Boolean bTemp1 // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // Use a previously obtained access token. The token should look something like this: // "AgAAAA**AQA ..." Move "EBAY_ACCESS_TOKEN" To sAccessToken Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End Move "uploadFile" To sApiCall Move "<urn:uuid:bb47b86a237311e793ae92361f002671>" To sFileAttachmentUuid Move "<urn:uuid:bb47b766237311e793ae92361f002671>" To sXmlUuid Get Create (RefClass(cComChilkatHttpRequest)) To hoReq If (Not(IsComObjectCreated(hoReq))) Begin Send CreateComObject of hoReq End Set ComHttpVerb Of hoReq To "POST" Set ComPath Of hoReq To "/FileTransferService" Get Create (RefClass(cComChilkatStringBuilder)) To hoSbContentType If (Not(IsComObjectCreated(hoSbContentType))) Begin Send CreateComObject of hoSbContentType End Get ComAppend Of hoSbContentType 'multipart/related; type="application/xop+xml"; start="XMLUUID"; start-info="text/xml"' To iSuccess Get ComReplace Of hoSbContentType "XMLUUID" sXmlUuid To iReplaceCount Get ComGetAsString Of hoSbContentType To sTemp1 Set ComContentType Of hoReq To sTemp1 Send ComAddHeader To hoReq "X-EBAY-SOA-SERVICE-NAME" "FileTransferService" Send ComAddHeader To hoReq "X-EBAY-SOA-OPERATION-NAME" sApiCall Send ComAddHeader To hoReq "X-EBAY-SOA-SECURITY-TOKEN" sAccessToken Send ComAddHeader To hoReq "X-EBAY-SOA-REQUEST-DATA-FORMAT" "XML" Send ComAddHeader To hoReq "X-EBAY-SOA-RESPONSE-DATA-FORMAT" "XML" Send ComAddHeader To hoReq "User-Agent" "AnythingYouWant" Move "qa_data/ebay/uploadFileRequest.xml" To sPathToFileOnDisk1 Get ComAddFileForUpload Of hoReq "uploadFileRequest.xml" sPathToFileOnDisk1 To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoReq To sTemp1 Showln sTemp1 Procedure_Return End Move "qa_data/ebay/BulkDataExchangeRequests.gz" To sPathToFileOnDisk2 Get ComAddFileForUpload Of hoReq "BulkDataExchangeRequests.gz" sPathToFileOnDisk2 To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoReq To sTemp1 Showln sTemp1 Procedure_Return End // Add sub-headers for each file in the request. Get ComAddSubHeader Of hoReq 0 "Content-Type" 'application/xop+xml; charset=UTF-8; type="text/xml"' To iSuccess Get ComAddSubHeader Of hoReq 0 "Content-Transfer-Encoding" "binary" To iSuccess Get ComAddSubHeader Of hoReq 0 "Content-ID" sXmlUuid To iSuccess Get ComAddSubHeader Of hoReq 1 "Content-Type" "application/octet-stream" To iSuccess Get ComAddSubHeader Of hoReq 1 "Content-Transfer-Encoding" "binary" To iSuccess Get ComAddSubHeader Of hoReq 1 "Content-ID" sFileAttachmentUuid To iSuccess Get pvComObject of hoReq to vReq Get ComSynchronousRequest Of hoHttp "storage.sandbox.ebay.com" 443 True vReq To vResp If (IsComObject(vResp)) Begin Get Create (RefClass(cComChilkatHttpResponse)) To hoResp Set pvComObject Of hoResp To vResp End Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Get ComStatusCode Of hoResp To iTemp1 Showln "Response status code = " iTemp1 Get Create (RefClass(cComChilkatXml)) To hoXml If (Not(IsComObjectCreated(hoXml))) Begin Send CreateComObject of hoXml End Get ComBodyStr Of hoResp To sTemp1 Get ComLoadXml Of hoXml sTemp1 To iSuccess Get ComStatusCode Of hoResp To iTemp1 If (iTemp1 <> 200) Begin Get ComGetXml Of hoXml To sTemp1 Showln sTemp1 Showln "Failed." Send Destroy of hoResp Procedure_Return End // We still may have a failure. The XML needs to be checked. // A failed response might look like this: // <?xml version="1.0" encoding="UTF-8" ?> // <uploadFileResponse xmlns="http://www.ebay.com/marketplace/services"> // <ack>Failure</ack> // <errorMessage> // <error> // <errorId>1</errorId> // <domain>Marketplace</domain> // <severity>Error</severity> // <category>Application</category> // <message>Task Reference Id is invalid</message> // <subdomain>FileTransfer</subdomain> // </error> // </errorMessage> // <version>1.1.0</version> // <timestamp>2017-04-18T01:05:27.475Z</timestamp> // </uploadFileResponse> // A successful response looks like this: // <?xml version="1.0" encoding="UTF-8" ?> // <uploadFileResponse xmlns="http://www.ebay.com/marketplace/services"> // <ack>Success</ack> // <version>1.1.0</version> // <timestamp>2017-04-18T01:22:47.853Z</timestamp> // </uploadFileResponse> Get ComGetXml Of hoXml To sTemp1 Showln sTemp1 // Get the "ack" to see if it's "Failure" or "Success" Get ComChildContentMatches Of hoXml "ack" "Success" False To bTemp1 If (bTemp1) Begin Showln "Success." End Else Begin Showln "Failure." End Send Destroy of hoResp End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.