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

PowerBuilder 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

 

 

 

(PowerBuilder) 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

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.