Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
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-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.