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

Visual Basic 6.0 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

 

 

 

(Visual Basic 6.0) Shippo Create Shipment Object

Create a Shipment object to retrieve rates. It represents a request to ship a given package from the sender to the recipient address.

For more information, see https://goshippo.com/docs/shipping-labels/

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

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

Dim http As New ChilkatHttp
Dim success As Long

' Implements the following CURL command:

' curl https://api.goshippo.com/shipments/  \
'     -H "Authorization: ShippoToken <API_TOKEN>" \
'     -H "Content-Type: application/json"  \
'     -d '{
'        "address_from":{
'           "name":"Mr. Hippo",
'           "street1":"215 Clayton St.",
'           "city":"San Francisco",
'           "state":"CA",
'           "zip":"94117",
'           "country":"US"
'        },
'        "address_to":{
'           "name":"Mrs. Hippo",
'           "street1":"965 Mission St.",
'           "city":"San Francisco",
'           "state":"CA",
'           "zip":"94105",
'           "country":"US"
'        },
'        "parcels":[{
'           "length":"5",
'           "width":"5",
'           "height":"5",
'           "distance_unit":"in",
'           "weight":"2",
'           "mass_unit":"lb"
'        }],
'        "async": false
'     }'

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

' The following JSON is sent in the request body.

' {
'   "address_from": {
'     "name": "Mr. Hippo",
'     "street1": "215 Clayton St.",
'     "city": "San Francisco",
'     "state": "CA",
'     "zip": "94117",
'     "country": "US"
'   },
'   "address_to": {
'     "name": "Mrs. Hippo",
'     "street1": "965 Mission St.",
'     "city": "San Francisco",
'     "state": "CA",
'     "zip": "94105",
'     "country": "US"
'   },
'   "parcels": [
'     {
'       "length": "5",
'       "width": "5",
'       "height": "5",
'       "distance_unit": "in",
'       "weight": "2",
'       "mass_unit": "lb"
'     }
'   ],
'   "async": false
' }

Dim json As New ChilkatJsonObject
success = json.UpdateString("address_from.name","Mr. Hippo")
success = json.UpdateString("address_from.street1","215 Clayton St.")
success = json.UpdateString("address_from.city","San Francisco")
success = json.UpdateString("address_from.state","CA")
success = json.UpdateString("address_from.zip","94117")
success = json.UpdateString("address_from.country","US")
success = json.UpdateString("address_to.name","Mrs. Hippo")
success = json.UpdateString("address_to.street1","965 Mission St.")
success = json.UpdateString("address_to.city","San Francisco")
success = json.UpdateString("address_to.state","CA")
success = json.UpdateString("address_to.zip","94105")
success = json.UpdateString("address_to.country","US")
success = json.UpdateString("parcels[0].length","5")
success = json.UpdateString("parcels[0].width","5")
success = json.UpdateString("parcels[0].height","5")
success = json.UpdateString("parcels[0].distance_unit","in")
success = json.UpdateString("parcels[0].weight","2")
success = json.UpdateString("parcels[0].mass_unit","lb")
success = json.UpdateBool("async",0)

http.SetRequestHeader "Authorization","ShippoToken <API_TOKEN>"
http.SetRequestHeader "Content-Type","application/json"

Dim resp As ChilkatHttpResponse
Set resp = http.PostJson3("https://api.goshippo.com/shipments/","application/json",json)
If (http.LastMethodSuccess = 0) Then
    Debug.Print http.LastErrorText
    Exit Sub
End If

Dim sbResponseBody As New ChilkatStringBuilder
success = resp.GetBodySb(sbResponseBody)
Dim jResp As New ChilkatJsonObject
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = 0

Debug.Print "Response Body:"
Debug.Print jResp.Emit()

Dim respStatusCode As Long
respStatusCode = resp.StatusCode
Debug.Print "Response Status Code = " & respStatusCode
If (respStatusCode >= 400) Then
    Debug.Print "Response Header:"
    Debug.Print resp.Header
    Debug.Print "Failed."

    Exit Sub
End If

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

' {
'   "carrier_accounts": [
'   ],
'   "object_created": "2019-06-28T17:45:20.441Z",
'   "object_updated": "2019-06-28T17:45:20.511Z",
'   "object_id": "17b01795a4884d8a9002ccc17c9d09d1",
'   "object_owner": "admin@chilkatsoft.com",
'   "status": "SUCCESS",
'   "address_from": {
'     "object_id": "427489906b604f498f7bd2429ab7d9a1",
'     "is_complete": true,
'     "name": "Mr. Hippo",
'     "company": "",
'     "street_no": "",
'     "street1": "215 Clayton St.",
'     "validation_results": {},
'     "street2": "",
'     "street3": "",
'     "city": "San Francisco",
'     "state": "CA",
'     "zip": "94117",
'     "country": "US",
'     "phone": "",
'     "email": "",
'     "is_residential": null,
'     "test": true
'   },
'   "address_to": {
'     "object_id": "3d7166269a2844b7842ef9ace942ec7c",
'     "is_complete": true,
'     "name": "Mrs. Hippo",
'     "company": "",
'     "street_no": "",
'     "street1": "965 Mission St.",
'     "validation_results": {},
'     "street2": "",
'     "street3": "",
'     "city": "San Francisco",
'     "state": "CA",
'     "zip": "94105",
'     "country": "US",
'     "phone": "",
'     "email": "",
'     "is_residential": null,
'     "test": true
'   },
'   "parcels": [
'     {
'       "object_state": "VALID",
'       "object_created": "2019-06-28T17:45:20.411Z",
'       "object_updated": "2019-06-28T17:45:20.455Z",
'       "object_id": "5af766ff15684a4186b0e3c833348fac",
'       "object_owner": "admin@chilkatsoft.com",
'       "template": null,
'       "extra": {},
'       "length": "5.0000",
'       "width": "5.0000",
'       "height": "5.0000",
'       "distance_unit": "in",
'       "weight": "2.0000",
'       "mass_unit": "lb",
'       "value_amount": null,
'       "value_currency": null,
'       "metadata": "",
'       "line_items": [
'       ],
'       "test": true
'     }
'   ],
'   "shipment_date": "2019-06-28T17:45:20.511Z",
'   "address_return": {
'     "object_id": "427489906b604f498f7bd2429ab7d9a1",
'     "is_complete": true,
'     "name": "Mr. Hippo",
'     "company": "",
'     "street_no": "",
'     "street1": "215 Clayton St.",
'     "validation_results": {},
'     "street2": "",
'     "street3": "",
'     "city": "San Francisco",
'     "state": "CA",
'     "zip": "94117",
'     "country": "US",
'     "phone": "",
'     "email": "",
'     "is_residential": null,
'     "test": true
'   },
'   "alternate_address_to": null,
'   "customs_declaration": null,
'   "extra": {},
'   "rates": [
'     {
'       "object_created": "2019-06-28T17:45:20.789Z",
'       "object_id": "dd7556c284e8444294d2ab7099e662d2",
'       "object_owner": "admin@chilkatsoft.com",
'       "shipment": "17b01795a4884d8a9002ccc17c9d09d1",
'       "attributes": [
'         "FASTEST"
'       ],
'       "amount": "22.78",
'       "currency": "USD",
'       "amount_local": "22.78",
'       "currency_local": "USD",
'       "provider": "USPS",
'       "provider_image_75": "https://shippo-static.s3.amazonaws.com/providers/75/USPS.png",
'       "provider_image_200": "https://shippo-static.s3.amazonaws.com/providers/200/USPS.png",
'       "servicelevel": {
'         "name": "Priority Mail Express",
'         "token": "usps_priority_express",
'         "terms": ""
'       },
'       "estimated_days": 2,
'       "arrives_by": null,
'       "duration_terms": "Overnight delivery to most U.S. locations.",
'       "messages": [
'       ],
'       "carrier_account": "1f3dc340ad6c4991ad61f14fa3e4b82e",
'       "test": true,
'       "zone": "1"
'     },
'     {
'       "object_created": "2019-06-28T17:45:20.786Z",
'       "object_id": "ec11cc297e2f4583986097f6d409e5c6",
'       "object_owner": "admin@chilkatsoft.com",
'       "shipment": "17b01795a4884d8a9002ccc17c9d09d1",
'       "attributes": [
'         "BESTVALUE",
'         "CHEAPEST",
'         "FASTEST"
'       ],
'       "amount": "6.95",
'       "currency": "USD",
'       "amount_local": "6.95",
'       "currency_local": "USD",
'       "provider": "USPS",
'       "provider_image_75": "https://shippo-static.s3.amazonaws.com/providers/75/USPS.png",
'       "provider_image_200": "https://shippo-static.s3.amazonaws.com/providers/200/USPS.png",
'       "servicelevel": {
'         "name": "Priority Mail",
'         "token": "usps_priority",
'         "terms": ""
'       },
'       "estimated_days": 2,
'       "arrives_by": null,
'       "duration_terms": "Delivery within 1, 2, or 3 days based on where your package started and where it’s being sent.",
'       "messages": [
'       ],
'       "carrier_account": "1f3dc340ad6c4991ad61f14fa3e4b82e",
'       "test": true,
'       "zone": "1"
'     },
'     {
'       "object_created": "2019-06-28T17:45:20.785Z",
'       "object_id": "d256586f539f4c93a2f02cc11f4942ac",
'       "object_owner": "admin@chilkatsoft.com",
'       "shipment": "17b01795a4884d8a9002ccc17c9d09d1",
'       "attributes": [
'       ],
'       "amount": "7.32",
'       "currency": "USD",
'       "amount_local": "7.32",
'       "currency_local": "USD",
'       "provider": "USPS",
'       "provider_image_75": "https://shippo-static.s3.amazonaws.com/providers/75/USPS.png",
'       "provider_image_200": "https://shippo-static.s3.amazonaws.com/providers/200/USPS.png",
'       "servicelevel": {
'         "name": "Parcel Select",
'         "token": "usps_parcel_select",
'         "terms": ""
'       },
'       "estimated_days": 7,
'       "arrives_by": null,
'       "duration_terms": "Delivery in 2 to 8 days.",
'       "messages": [
'       ],
'       "carrier_account": "1f3dc340ad6c4991ad61f14fa3e4b82e",
'       "test": true,
'       "zone": "1"
'     }
'   ],
'   "messages": [
'     {
'       "source": "DHLExpress",
'       "code": "",
'       "text": "Shippo's DHL Express master account doesn't support shipments to inside of the US"
'     }
'   ],
'   "metadata": "",
'   "test": true,
'   "order": 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 object_state As String
Dim template As String
Dim length As String
Dim width As String
Dim height As String
Dim distance_unit As String
Dim weight As String
Dim mass_unit As String
Dim value_amount As String
Dim value_currency As String
Dim j As Long
Dim count_j As Long
Dim shipment As String
Dim amount As String
Dim currency As String
Dim amount_local As String
Dim currency_local As String
Dim provider As String
Dim provider_image_75 As String
Dim provider_image_200 As String
Dim servicelevelName As String
Dim servicelevelToken As String
Dim servicelevelTerms As String
Dim estimated_days As Long
Dim arrives_by As String
Dim duration_terms As String
Dim carrier_account As String
Dim zone As String
Dim strVal As String
Dim source As String
Dim code As String
Dim text 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 status As String
status = jResp.StringOf("status")
Dim address_fromObject_id As String
address_fromObject_id = jResp.StringOf("address_from.object_id")
Dim address_fromIs_complete As Long
address_fromIs_complete = jResp.BoolOf("address_from.is_complete")
Dim address_fromName As String
address_fromName = jResp.StringOf("address_from.name")
Dim address_fromCompany As String
address_fromCompany = jResp.StringOf("address_from.company")
Dim address_fromStreet_no As String
address_fromStreet_no = jResp.StringOf("address_from.street_no")
Dim address_fromStreet1 As String
address_fromStreet1 = jResp.StringOf("address_from.street1")
Dim address_fromStreet2 As String
address_fromStreet2 = jResp.StringOf("address_from.street2")
Dim address_fromStreet3 As String
address_fromStreet3 = jResp.StringOf("address_from.street3")
Dim address_fromCity As String
address_fromCity = jResp.StringOf("address_from.city")
Dim address_fromState As String
address_fromState = jResp.StringOf("address_from.state")
Dim address_fromZip As String
address_fromZip = jResp.StringOf("address_from.zip")
Dim address_fromCountry As String
address_fromCountry = jResp.StringOf("address_from.country")
Dim address_fromPhone As String
address_fromPhone = jResp.StringOf("address_from.phone")
Dim address_fromEmail As String
address_fromEmail = jResp.StringOf("address_from.email")
Dim address_fromIs_residential As String
address_fromIs_residential = jResp.StringOf("address_from.is_residential")
Dim address_fromTest As Long
address_fromTest = jResp.BoolOf("address_from.test")
Dim address_toObject_id As String
address_toObject_id = jResp.StringOf("address_to.object_id")
Dim address_toIs_complete As Long
address_toIs_complete = jResp.BoolOf("address_to.is_complete")
Dim address_toName As String
address_toName = jResp.StringOf("address_to.name")
Dim address_toCompany As String
address_toCompany = jResp.StringOf("address_to.company")
Dim address_toStreet_no As String
address_toStreet_no = jResp.StringOf("address_to.street_no")
Dim address_toStreet1 As String
address_toStreet1 = jResp.StringOf("address_to.street1")
Dim address_toStreet2 As String
address_toStreet2 = jResp.StringOf("address_to.street2")
Dim address_toStreet3 As String
address_toStreet3 = jResp.StringOf("address_to.street3")
Dim address_toCity As String
address_toCity = jResp.StringOf("address_to.city")
Dim address_toState As String
address_toState = jResp.StringOf("address_to.state")
Dim address_toZip As String
address_toZip = jResp.StringOf("address_to.zip")
Dim address_toCountry As String
address_toCountry = jResp.StringOf("address_to.country")
Dim address_toPhone As String
address_toPhone = jResp.StringOf("address_to.phone")
Dim address_toEmail As String
address_toEmail = jResp.StringOf("address_to.email")
Dim address_toIs_residential As String
address_toIs_residential = jResp.StringOf("address_to.is_residential")
Dim address_toTest As Long
address_toTest = jResp.BoolOf("address_to.test")
Dim shipment_date As String
shipment_date = jResp.StringOf("shipment_date")
Dim address_returnObject_id As String
address_returnObject_id = jResp.StringOf("address_return.object_id")
Dim address_returnIs_complete As Long
address_returnIs_complete = jResp.BoolOf("address_return.is_complete")
Dim address_returnName As String
address_returnName = jResp.StringOf("address_return.name")
Dim address_returnCompany As String
address_returnCompany = jResp.StringOf("address_return.company")
Dim address_returnStreet_no As String
address_returnStreet_no = jResp.StringOf("address_return.street_no")
Dim address_returnStreet1 As String
address_returnStreet1 = jResp.StringOf("address_return.street1")
Dim address_returnStreet2 As String
address_returnStreet2 = jResp.StringOf("address_return.street2")
Dim address_returnStreet3 As String
address_returnStreet3 = jResp.StringOf("address_return.street3")
Dim address_returnCity As String
address_returnCity = jResp.StringOf("address_return.city")
Dim address_returnState As String
address_returnState = jResp.StringOf("address_return.state")
Dim address_returnZip As String
address_returnZip = jResp.StringOf("address_return.zip")
Dim address_returnCountry As String
address_returnCountry = jResp.StringOf("address_return.country")
Dim address_returnPhone As String
address_returnPhone = jResp.StringOf("address_return.phone")
Dim address_returnEmail As String
address_returnEmail = jResp.StringOf("address_return.email")
Dim address_returnIs_residential As String
address_returnIs_residential = jResp.StringOf("address_return.is_residential")
Dim address_returnTest As Long
address_returnTest = jResp.BoolOf("address_return.test")
Dim alternate_address_to As String
alternate_address_to = jResp.StringOf("alternate_address_to")
Dim customs_declaration As String
customs_declaration = jResp.StringOf("customs_declaration")
Dim metadata As String
metadata = jResp.StringOf("metadata")
Dim test As Long
test = jResp.BoolOf("test")
Dim order As String
order = jResp.StringOf("order")
Dim i As Long
i = 0
Dim count_i As Long
count_i = jResp.SizeOfArray("carrier_accounts")
Do While i < count_i
    jResp.I = i
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("parcels")
Do While i < count_i
    jResp.I = i
    object_state = jResp.StringOf("parcels[i].object_state")
    object_created = jResp.StringOf("parcels[i].object_created")
    object_updated = jResp.StringOf("parcels[i].object_updated")
    object_id = jResp.StringOf("parcels[i].object_id")
    object_owner = jResp.StringOf("parcels[i].object_owner")
    template = jResp.StringOf("parcels[i].template")
    length = jResp.StringOf("parcels[i].length")
    width = jResp.StringOf("parcels[i].width")
    height = jResp.StringOf("parcels[i].height")
    distance_unit = jResp.StringOf("parcels[i].distance_unit")
    weight = jResp.StringOf("parcels[i].weight")
    mass_unit = jResp.StringOf("parcels[i].mass_unit")
    value_amount = jResp.StringOf("parcels[i].value_amount")
    value_currency = jResp.StringOf("parcels[i].value_currency")
    metadata = jResp.StringOf("parcels[i].metadata")
    test = jResp.BoolOf("parcels[i].test")
    j = 0
    count_j = jResp.SizeOfArray("parcels[i].line_items")
    Do While j < count_j
        jResp.J = j
        j = j + 1
    Loop
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("rates")
Do While i < count_i
    jResp.I = i
    object_created = jResp.StringOf("rates[i].object_created")
    object_id = jResp.StringOf("rates[i].object_id")
    object_owner = jResp.StringOf("rates[i].object_owner")
    shipment = jResp.StringOf("rates[i].shipment")
    amount = jResp.StringOf("rates[i].amount")
    currency = jResp.StringOf("rates[i].currency")
    amount_local = jResp.StringOf("rates[i].amount_local")
    currency_local = jResp.StringOf("rates[i].currency_local")
    provider = jResp.StringOf("rates[i].provider")
    provider_image_75 = jResp.StringOf("rates[i].provider_image_75")
    provider_image_200 = jResp.StringOf("rates[i].provider_image_200")
    servicelevelName = jResp.StringOf("rates[i].servicelevel.name")
    servicelevelToken = jResp.StringOf("rates[i].servicelevel.token")
    servicelevelTerms = jResp.StringOf("rates[i].servicelevel.terms")
    estimated_days = jResp.IntOf("rates[i].estimated_days")
    arrives_by = jResp.StringOf("rates[i].arrives_by")
    duration_terms = jResp.StringOf("rates[i].duration_terms")
    carrier_account = jResp.StringOf("rates[i].carrier_account")
    test = jResp.BoolOf("rates[i].test")
    zone = jResp.StringOf("rates[i].zone")
    j = 0
    count_j = jResp.SizeOfArray("rates[i].attributes")
    Do While j < count_j
        jResp.J = j
        strVal = jResp.StringOf("rates[i].attributes[j]")
        j = j + 1
    Loop
    j = 0
    count_j = jResp.SizeOfArray("rates[i].messages")
    Do While j < count_j
        jResp.J = j
        j = j + 1
    Loop
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("messages")
Do While i < count_i
    jResp.I = i
    source = jResp.StringOf("messages[i].source")
    code = jResp.StringOf("messages[i].code")
    text = jResp.StringOf("messages[i].text")
    i = i + 1
Loop

 

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