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
(PowerBuilder) eBay -- Upload Bulk Data using FileTransferServiceDemonstrates how to upload your data file using the eBay File Transfer API.
integer li_rc string ls_AccessToken oleobject loo_Http string ls_ApiCall string ls_FileAttachmentUuid string ls_XmlUuid oleobject loo_Req oleobject loo_SbContentType integer li_ReplaceCount string ls_PathToFileOnDisk1 integer li_Success string ls_PathToFileOnDisk2 oleobject loo_Resp oleobject loo_Xml // 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 ..." ls_AccessToken = "EBAY_ACCESS_TOKEN" loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if ls_ApiCall = "uploadFile" ls_FileAttachmentUuid = "<urn:uuid:bb47b86a237311e793ae92361f002671>" ls_XmlUuid = "<urn:uuid:bb47b766237311e793ae92361f002671>" loo_Req = create oleobject // Use "Chilkat_9_5_0.HttpRequest" for versions of Chilkat < 10.0.0 li_rc = loo_Req.ConnectToNewObject("Chilkat.HttpRequest") loo_Req.HttpVerb = "POST" loo_Req.Path = "/FileTransferService" loo_SbContentType = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbContentType.ConnectToNewObject("Chilkat.StringBuilder") loo_SbContentType.Append("multipart/related; type=~"application/xop+xml~"; start=~"XMLUUID~"; start-info=~"text/xml~"") li_ReplaceCount = loo_SbContentType.Replace("XMLUUID",ls_XmlUuid) loo_Req.ContentType = loo_SbContentType.GetAsString() loo_Req.AddHeader("X-EBAY-SOA-SERVICE-NAME","FileTransferService") loo_Req.AddHeader("X-EBAY-SOA-OPERATION-NAME",ls_ApiCall) loo_Req.AddHeader("X-EBAY-SOA-SECURITY-TOKEN",ls_AccessToken) loo_Req.AddHeader("X-EBAY-SOA-REQUEST-DATA-FORMAT","XML") loo_Req.AddHeader("X-EBAY-SOA-RESPONSE-DATA-FORMAT","XML") loo_Req.AddHeader("User-Agent","AnythingYouWant") ls_PathToFileOnDisk1 = "qa_data/ebay/uploadFileRequest.xml" li_Success = loo_Req.AddFileForUpload("uploadFileRequest.xml",ls_PathToFileOnDisk1) if li_Success <> 1 then Write-Debug loo_Req.LastErrorText destroy loo_Http destroy loo_Req destroy loo_SbContentType return end if ls_PathToFileOnDisk2 = "qa_data/ebay/BulkDataExchangeRequests.gz" li_Success = loo_Req.AddFileForUpload("BulkDataExchangeRequests.gz",ls_PathToFileOnDisk2) if li_Success <> 1 then Write-Debug loo_Req.LastErrorText destroy loo_Http destroy loo_Req destroy loo_SbContentType return end if // Add sub-headers for each file in the request. loo_Req.AddSubHeader(0,"Content-Type","application/xop+xml; charset=UTF-8; type=~"text/xml~"") loo_Req.AddSubHeader(0,"Content-Transfer-Encoding","binary") loo_Req.AddSubHeader(0,"Content-ID",ls_XmlUuid) loo_Req.AddSubHeader(1,"Content-Type","application/octet-stream") loo_Req.AddSubHeader(1,"Content-Transfer-Encoding","binary") loo_Req.AddSubHeader(1,"Content-ID",ls_FileAttachmentUuid) loo_Resp = loo_Http.SynchronousRequest("storage.sandbox.ebay.com",443,1,loo_Req) if loo_Http.LastMethodSuccess <> 1 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_Req destroy loo_SbContentType return end if Write-Debug "Response status code = " + string(loo_Resp.StatusCode) loo_Xml = create oleobject // Use "Chilkat_9_5_0.Xml" for versions of Chilkat < 10.0.0 li_rc = loo_Xml.ConnectToNewObject("Chilkat.Xml") loo_Xml.LoadXml(loo_Resp.BodyStr) if loo_Resp.StatusCode <> 200 then Write-Debug loo_Xml.GetXml() Write-Debug "Failed." destroy loo_Resp destroy loo_Http destroy loo_Req destroy loo_SbContentType destroy loo_Xml return end if // 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> Write-Debug loo_Xml.GetXml() // Get the "ack" to see if it's "Failure" or "Success" if loo_Xml.ChildContentMatches("ack","Success",0) then Write-Debug "Success." else Write-Debug "Failure." end if destroy loo_Resp destroy loo_Http destroy loo_Req destroy loo_SbContentType destroy loo_Xml |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.