Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

DataFlex Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Bitfinex v2 REST
Bluzone
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun

MedTunnel
MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Okta OAuth/OIDC
OneLogin OIDC
OneNote
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter
UniPin
VoiceBase
Vonage
Walmart
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yousign
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(DataFlex) eBay -- Upload Bulk Data using FileTransferService

Demonstrates how to upload your data file using the eBay File Transfer API.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    String sAccessToken
    Handle hoHttp
    String sApiCall
    String sFileAttachmentUuid
    String sXmlUuid
    Variant vReq
    Handle hoReq
    Handle hoSbContentType
    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-2022 Chilkat Software, Inc. All Rights Reserved.