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
(Xojo Plugin) Shippo Create Customs DeclarationDemonstrates 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/
// This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Dim http As New Chilkat.Http Dim success As Boolean // 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" // } // ] // } Dim json As New Chilkat.JsonObject success = json.UpdateString("contents_type","MERCHANDISE") success = json.UpdateString("non_delivery_option","RETURN") success = json.UpdateBool("certify",True) success = json.UpdateString("certify_signer","Simon Kreuz") success = json.UpdateString("incoterm","DDU") success = json.UpdateString("items[0].description","T-shirt") success = json.UpdateInt("items[0].quantity",20) success = json.UpdateString("items[0].net_weight","5") success = json.UpdateString("items[0].mass_unit","lb") success = json.UpdateString("items[0].value_amount","200") success = json.UpdateString("items[0].value_currency","USD") success = json.UpdateString("items[0].tariff_number","") success = json.UpdateString("items[0].origin_country","US") http.SetRequestHeader "Authorization","ShippoToken <API_TOKEN>" http.SetRequestHeader "Content-Type","application/json" Dim resp As Chilkat.HttpResponse resp = http.PostJson3("https://api.goshippo.com/customs/declarations/","application/json",json) If (http.LastMethodSuccess = False) Then System.DebugLog(http.LastErrorText) Return End If Dim sbResponseBody As New Chilkat.StringBuilder success = resp.GetBodySb(sbResponseBody) Dim jResp As New Chilkat.JsonObject success = jResp.LoadSb(sbResponseBody) jResp.EmitCompact = False System.DebugLog("Response Body:") System.DebugLog(jResp.Emit()) Dim respStatusCode As Int32 respStatusCode = resp.StatusCode System.DebugLog("Response Status Code = " + Str(respStatusCode)) If (respStatusCode >= 400) Then System.DebugLog("Response Header:") System.DebugLog(resp.Header) System.DebugLog("Failed.") Return End If // 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 Dim strVal As String Dim object_created As String object_created = jResp.StringOf("object_created") Dim object_updated As String object_updated = jResp.StringOf("object_updated") Dim object_id As String object_id = jResp.StringOf("object_id") Dim object_owner As String object_owner = jResp.StringOf("object_owner") Dim object_state As String object_state = jResp.StringOf("object_state") Dim address_importer As String address_importer = jResp.StringOf("address_importer") Dim certify_signer As String certify_signer = jResp.StringOf("certify_signer") Dim certify As Boolean certify = jResp.BoolOf("certify") Dim non_delivery_option As String non_delivery_option = jResp.StringOf("non_delivery_option") Dim contents_type As String contents_type = jResp.StringOf("contents_type") Dim contents_explanation As String contents_explanation = jResp.StringOf("contents_explanation") Dim exporter_reference As String exporter_reference = jResp.StringOf("exporter_reference") Dim importer_reference As String importer_reference = jResp.StringOf("importer_reference") Dim invoice As String invoice = jResp.StringOf("invoice") Dim commercial_invoice As Boolean commercial_invoice = jResp.BoolOf("commercial_invoice") Dim license As String license = jResp.StringOf("license") Dim certificate As String certificate = jResp.StringOf("certificate") Dim notes As String notes = jResp.StringOf("notes") Dim eel_pfc As String eel_pfc = jResp.StringOf("eel_pfc") Dim aes_itn As String aes_itn = jResp.StringOf("aes_itn") Dim disclaimer As String disclaimer = jResp.StringOf("disclaimer") Dim incoterm As String incoterm = jResp.StringOf("incoterm") Dim metadata As String metadata = jResp.StringOf("metadata") Dim test As Boolean test = jResp.BoolOf("test") Dim duties_payor As String duties_payor = jResp.StringOf("duties_payor") Dim i As Int32 i = 0 Dim count_i As Int32 count_i = jResp.SizeOfArray("items") While i < count_i jResp.I = i strVal = jResp.StringOf("items[i]") i = i + 1 Wend |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.