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

Visual FoxPro Web API Examples

Primary Categories

ABN AMRO
AWS Translate
Activix CRM
Adyen
Amazon MWS
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bitfinex v2 REST
Bluzone
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Hungary NAV Invoicing
IBM Text to Speech
Jira
MYOB
Magento

MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
Rabobank
SOAP finkok.com
Shippo
Shopify
SimpleTexting
Square
Stripe
SugarCRM
Trello
Twilio
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
WhatsApp
WooCommerce
Xero
Yousign
_Miscellaneous_
eBay
effectconnect

 

 

 

(Visual FoxPro) Shippo Create Customs Declaration

Demonstrates how to create a customs declaration and send a POST request with the necessary information to the Customs Declarations endpoint.

For more information, see https://goshippo.com/docs/international/

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcStrVal
LOCAL lcObject_created
LOCAL lcObject_updated
LOCAL lcObject_id
LOCAL lcObject_owner
LOCAL lcObject_state
LOCAL lcAddress_importer
LOCAL lcCertify_signer
LOCAL lnCertify
LOCAL lcNon_delivery_option
LOCAL lcContents_type
LOCAL lcContents_explanation
LOCAL lcExporter_reference
LOCAL lcImporter_reference
LOCAL lcInvoice
LOCAL lnCommercial_invoice
LOCAL lcLicense
LOCAL lcCertificate
LOCAL lcNotes
LOCAL lcEel_pfc
LOCAL lcAes_itn
LOCAL lcDisclaimer
LOCAL lcIncoterm
LOCAL lcMetadata
LOCAL lnTest
LOCAL lcDuties_payor
LOCAL i
LOCAL lnCount_i

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

loHttp = CreateObject('Chilkat_9_5_0.Http')

* Implements the following CURL command:

* curl https://api.goshippo.com/customs/declarations/ \
*     -H "Authorization: ShippoToken <API_TOKEN>" \
*     -H "Content-Type: application/json"  \
*     -d '{          
*           "contents_type": "MERCHANDISE",
*           "non_delivery_option": "RETURN",
*           "certify": true,
*           "certify_signer": "Simon Kreuz",
*           "incoterm": "DDU",
*           "items": [{
*                     "description": "T-shirt",
*                     "quantity": 20,
*                     "net_weight": "5",
*                     "mass_unit": "lb",
*                     "value_amount": "200",
*                     "value_currency": "USD",
*                     "tariff_number": "",
*                     "origin_country": "US"
*             }]
*     }'

* Use this online tool to generate code from sample JSON:
* Generate Code to Create JSON

* The following JSON is sent in the request body.

* {
*   "contents_type": "MERCHANDISE",
*   "non_delivery_option": "RETURN",
*   "certify": true,
*   "certify_signer": "Simon Kreuz",
*   "incoterm": "DDU",
*   "items": [
*     {
*       "description": "T-shirt",
*       "quantity": 20,
*       "net_weight": "5",
*       "mass_unit": "lb",
*       "value_amount": "200",
*       "value_currency": "USD",
*       "tariff_number": "",
*       "origin_country": "US"
*     }
*   ]
* }

loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateString("contents_type","MERCHANDISE")
loJson.UpdateString("non_delivery_option","RETURN")
loJson.UpdateBool("certify",1)
loJson.UpdateString("certify_signer","Simon Kreuz")
loJson.UpdateString("incoterm","DDU")
loJson.UpdateString("items[0].description","T-shirt")
loJson.UpdateInt("items[0].quantity",20)
loJson.UpdateString("items[0].net_weight","5")
loJson.UpdateString("items[0].mass_unit","lb")
loJson.UpdateString("items[0].value_amount","200")
loJson.UpdateString("items[0].value_currency","USD")
loJson.UpdateString("items[0].tariff_number","")
loJson.UpdateString("items[0].origin_country","US")

loHttp.SetRequestHeader("Authorization","ShippoToken <API_TOKEN>")
loHttp.SetRequestHeader("Content-Type","application/json")

loResp = loHttp.PostJson3("https://api.goshippo.com/customs/declarations/","application/json",loJson)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loJson
    CANCEL
ENDIF

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loResp.GetBodySb(loSbResponseBody)
loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loResp.Header
    ? "Failed."
    RELEASE loResp
    RELEASE loHttp
    RELEASE loJson
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

RELEASE loResp

* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)

* {
*   "object_created": "2019-07-04T16:00:29.043Z",
*   "object_updated": "2019-07-04T16:00:29.043Z",
*   "object_id": "4a1e6ab7b1ba49ed9bc6cb1a8798e0fd",
*   "object_owner": "admin@chilkatsoft.com",
*   "object_state": "VALID",
*   "address_importer": null,
*   "certify_signer": "Simon Kreuz",
*   "certify": true,
*   "items": [
*     "4096c68693364b7ea0af72fb869ee861"
*   ],
*   "non_delivery_option": "RETURN",
*   "contents_type": "MERCHANDISE",
*   "contents_explanation": "",
*   "exporter_reference": "",
*   "importer_reference": "",
*   "invoice": "",
*   "commercial_invoice": false,
*   "license": "",
*   "certificate": "",
*   "notes": "",
*   "eel_pfc": "",
*   "aes_itn": "",
*   "disclaimer": "",
*   "incoterm": "DDU",
*   "metadata": "",
*   "test": true,
*   "duties_payor": null
* }

* Sample code for parsing the JSON response...
* Use the following online tool to generate parsing code from sample JSON:
* Generate Parsing Code from JSON

lcObject_created = loJResp.StringOf("object_created")
lcObject_updated = loJResp.StringOf("object_updated")
lcObject_id = loJResp.StringOf("object_id")
lcObject_owner = loJResp.StringOf("object_owner")
lcObject_state = loJResp.StringOf("object_state")
lcAddress_importer = loJResp.StringOf("address_importer")
lcCertify_signer = loJResp.StringOf("certify_signer")
lnCertify = loJResp.BoolOf("certify")
lcNon_delivery_option = loJResp.StringOf("non_delivery_option")
lcContents_type = loJResp.StringOf("contents_type")
lcContents_explanation = loJResp.StringOf("contents_explanation")
lcExporter_reference = loJResp.StringOf("exporter_reference")
lcImporter_reference = loJResp.StringOf("importer_reference")
lcInvoice = loJResp.StringOf("invoice")
lnCommercial_invoice = loJResp.BoolOf("commercial_invoice")
lcLicense = loJResp.StringOf("license")
lcCertificate = loJResp.StringOf("certificate")
lcNotes = loJResp.StringOf("notes")
lcEel_pfc = loJResp.StringOf("eel_pfc")
lcAes_itn = loJResp.StringOf("aes_itn")
lcDisclaimer = loJResp.StringOf("disclaimer")
lcIncoterm = loJResp.StringOf("incoterm")
lcMetadata = loJResp.StringOf("metadata")
lnTest = loJResp.BoolOf("test")
lcDuties_payor = loJResp.StringOf("duties_payor")
i = 0
lnCount_i = loJResp.SizeOfArray("items")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcStrVal = loJResp.StringOf("items[i]")
    i = i + 1
ENDDO

RELEASE loHttp
RELEASE loJson
RELEASE loSbResponseBody
RELEASE loJResp


 

© 2000-2020 Chilkat Software, Inc. All Rights Reserved.