AutoIt
AutoIt
Shippo Create Shipment Object
See more Shippo Examples
Create a Shipment object to retrieve rates. It represents a request to ship a given package from the sender to the recipient address.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
; 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
; }
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("address_from.name","Mr. Hippo")
$oJson.UpdateString("address_from.street1","215 Clayton St.")
$oJson.UpdateString("address_from.city","San Francisco")
$oJson.UpdateString("address_from.state","CA")
$oJson.UpdateString("address_from.zip","94117")
$oJson.UpdateString("address_from.country","US")
$oJson.UpdateString("address_to.name","Mrs. Hippo")
$oJson.UpdateString("address_to.street1","965 Mission St.")
$oJson.UpdateString("address_to.city","San Francisco")
$oJson.UpdateString("address_to.state","CA")
$oJson.UpdateString("address_to.zip","94105")
$oJson.UpdateString("address_to.country","US")
$oJson.UpdateString("parcels[0].length","5")
$oJson.UpdateString("parcels[0].width","5")
$oJson.UpdateString("parcels[0].height","5")
$oJson.UpdateString("parcels[0].distance_unit","in")
$oJson.UpdateString("parcels[0].weight","2")
$oJson.UpdateString("parcels[0].mass_unit","lb")
$oJson.UpdateBool("async",False)
$oHttp.SetRequestHeader "Authorization","ShippoToken <API_TOKEN>"
$oHttp.SetRequestHeader "Content-Type","application/json"
$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpJson("POST","https://api.goshippo.com/shipments/",$oJson,"application/json",$oResp)
If ($bSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$oResp.GetBodySb($oSbResponseBody)
$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False
ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)
Local $iRespStatusCode = $oResp.StatusCode
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
ConsoleWrite("Response Header:" & @CRLF)
ConsoleWrite($oResp.Header & @CRLF)
ConsoleWrite("Failed." & @CRLF)
Exit
EndIf
; 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
Local $sObject_state
Local $sTemplate
Local $sLength
Local $sWidth
Local $sHeight
Local $sDistance_unit
Local $sWeight
Local $sMass_unit
Local $sValue_amount
Local $sValue_currency
Local $iJ
Local $iCount_j
Local $shipment
Local $sAmount
Local $sCurrency
Local $sAmount_local
Local $sCurrency_local
Local $sProvider
Local $sProvider_image_75
Local $sProvider_image_200
Local $servicelevelName
Local $servicelevelToken
Local $servicelevelTerms
Local $iEstimated_days
Local $sArrives_by
Local $sDuration_terms
Local $sCarrier_account
Local $sZone
Local $strVal
Local $source
Local $sCode
Local $sText
Local $sObject_created = $oJResp.StringOf("object_created")
Local $sObject_updated = $oJResp.StringOf("object_updated")
Local $sObject_id = $oJResp.StringOf("object_id")
Local $sObject_owner = $oJResp.StringOf("object_owner")
Local $status = $oJResp.StringOf("status")
Local $sAddress_fromObject_id = $oJResp.StringOf("address_from.object_id")
Local $bAddress_fromIs_complete = $oJResp.BoolOf("address_from.is_complete")
Local $sAddress_fromName = $oJResp.StringOf("address_from.name")
Local $sAddress_fromCompany = $oJResp.StringOf("address_from.company")
Local $sAddress_fromStreet_no = $oJResp.StringOf("address_from.street_no")
Local $sAddress_fromStreet1 = $oJResp.StringOf("address_from.street1")
Local $sAddress_fromStreet2 = $oJResp.StringOf("address_from.street2")
Local $sAddress_fromStreet3 = $oJResp.StringOf("address_from.street3")
Local $sAddress_fromCity = $oJResp.StringOf("address_from.city")
Local $sAddress_fromState = $oJResp.StringOf("address_from.state")
Local $sAddress_fromZip = $oJResp.StringOf("address_from.zip")
Local $sAddress_fromCountry = $oJResp.StringOf("address_from.country")
Local $sAddress_fromPhone = $oJResp.StringOf("address_from.phone")
Local $sAddress_fromEmail = $oJResp.StringOf("address_from.email")
Local $sAddress_fromIs_residential = $oJResp.StringOf("address_from.is_residential")
Local $bAddress_fromTest = $oJResp.BoolOf("address_from.test")
Local $sAddress_toObject_id = $oJResp.StringOf("address_to.object_id")
Local $bAddress_toIs_complete = $oJResp.BoolOf("address_to.is_complete")
Local $sAddress_toName = $oJResp.StringOf("address_to.name")
Local $sAddress_toCompany = $oJResp.StringOf("address_to.company")
Local $sAddress_toStreet_no = $oJResp.StringOf("address_to.street_no")
Local $sAddress_toStreet1 = $oJResp.StringOf("address_to.street1")
Local $sAddress_toStreet2 = $oJResp.StringOf("address_to.street2")
Local $sAddress_toStreet3 = $oJResp.StringOf("address_to.street3")
Local $sAddress_toCity = $oJResp.StringOf("address_to.city")
Local $sAddress_toState = $oJResp.StringOf("address_to.state")
Local $sAddress_toZip = $oJResp.StringOf("address_to.zip")
Local $sAddress_toCountry = $oJResp.StringOf("address_to.country")
Local $sAddress_toPhone = $oJResp.StringOf("address_to.phone")
Local $sAddress_toEmail = $oJResp.StringOf("address_to.email")
Local $sAddress_toIs_residential = $oJResp.StringOf("address_to.is_residential")
Local $bAddress_toTest = $oJResp.BoolOf("address_to.test")
Local $shipment_date = $oJResp.StringOf("shipment_date")
Local $sAddress_returnObject_id = $oJResp.StringOf("address_return.object_id")
Local $bAddress_returnIs_complete = $oJResp.BoolOf("address_return.is_complete")
Local $sAddress_returnName = $oJResp.StringOf("address_return.name")
Local $sAddress_returnCompany = $oJResp.StringOf("address_return.company")
Local $sAddress_returnStreet_no = $oJResp.StringOf("address_return.street_no")
Local $sAddress_returnStreet1 = $oJResp.StringOf("address_return.street1")
Local $sAddress_returnStreet2 = $oJResp.StringOf("address_return.street2")
Local $sAddress_returnStreet3 = $oJResp.StringOf("address_return.street3")
Local $sAddress_returnCity = $oJResp.StringOf("address_return.city")
Local $sAddress_returnState = $oJResp.StringOf("address_return.state")
Local $sAddress_returnZip = $oJResp.StringOf("address_return.zip")
Local $sAddress_returnCountry = $oJResp.StringOf("address_return.country")
Local $sAddress_returnPhone = $oJResp.StringOf("address_return.phone")
Local $sAddress_returnEmail = $oJResp.StringOf("address_return.email")
Local $sAddress_returnIs_residential = $oJResp.StringOf("address_return.is_residential")
Local $bAddress_returnTest = $oJResp.BoolOf("address_return.test")
Local $sAlternate_address_to = $oJResp.StringOf("alternate_address_to")
Local $sCustoms_declaration = $oJResp.StringOf("customs_declaration")
Local $sMetadata = $oJResp.StringOf("metadata")
Local $bTest = $oJResp.BoolOf("test")
Local $sOrder = $oJResp.StringOf("order")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("carrier_accounts")
While $i < $iCount_i
$oJResp.I = $i
$i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("parcels")
While $i < $iCount_i
$oJResp.I = $i
$sObject_state = $oJResp.StringOf("parcels[i].object_state")
$sObject_created = $oJResp.StringOf("parcels[i].object_created")
$sObject_updated = $oJResp.StringOf("parcels[i].object_updated")
$sObject_id = $oJResp.StringOf("parcels[i].object_id")
$sObject_owner = $oJResp.StringOf("parcels[i].object_owner")
$sTemplate = $oJResp.StringOf("parcels[i].template")
$sLength = $oJResp.StringOf("parcels[i].length")
$sWidth = $oJResp.StringOf("parcels[i].width")
$sHeight = $oJResp.StringOf("parcels[i].height")
$sDistance_unit = $oJResp.StringOf("parcels[i].distance_unit")
$sWeight = $oJResp.StringOf("parcels[i].weight")
$sMass_unit = $oJResp.StringOf("parcels[i].mass_unit")
$sValue_amount = $oJResp.StringOf("parcels[i].value_amount")
$sValue_currency = $oJResp.StringOf("parcels[i].value_currency")
$sMetadata = $oJResp.StringOf("parcels[i].metadata")
$bTest = $oJResp.BoolOf("parcels[i].test")
$iJ = 0
$iCount_j = $oJResp.SizeOfArray("parcels[i].line_items")
While $iJ < $iCount_j
$oJResp.J = $iJ
$iJ = $iJ + 1
Wend
$i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("rates")
While $i < $iCount_i
$oJResp.I = $i
$sObject_created = $oJResp.StringOf("rates[i].object_created")
$sObject_id = $oJResp.StringOf("rates[i].object_id")
$sObject_owner = $oJResp.StringOf("rates[i].object_owner")
$shipment = $oJResp.StringOf("rates[i].shipment")
$sAmount = $oJResp.StringOf("rates[i].amount")
$sCurrency = $oJResp.StringOf("rates[i].currency")
$sAmount_local = $oJResp.StringOf("rates[i].amount_local")
$sCurrency_local = $oJResp.StringOf("rates[i].currency_local")
$sProvider = $oJResp.StringOf("rates[i].provider")
$sProvider_image_75 = $oJResp.StringOf("rates[i].provider_image_75")
$sProvider_image_200 = $oJResp.StringOf("rates[i].provider_image_200")
$servicelevelName = $oJResp.StringOf("rates[i].servicelevel.name")
$servicelevelToken = $oJResp.StringOf("rates[i].servicelevel.token")
$servicelevelTerms = $oJResp.StringOf("rates[i].servicelevel.terms")
$iEstimated_days = $oJResp.IntOf("rates[i].estimated_days")
$sArrives_by = $oJResp.StringOf("rates[i].arrives_by")
$sDuration_terms = $oJResp.StringOf("rates[i].duration_terms")
$sCarrier_account = $oJResp.StringOf("rates[i].carrier_account")
$bTest = $oJResp.BoolOf("rates[i].test")
$sZone = $oJResp.StringOf("rates[i].zone")
$iJ = 0
$iCount_j = $oJResp.SizeOfArray("rates[i].attributes")
While $iJ < $iCount_j
$oJResp.J = $iJ
$strVal = $oJResp.StringOf("rates[i].attributes[j]")
$iJ = $iJ + 1
Wend
$iJ = 0
$iCount_j = $oJResp.SizeOfArray("rates[i].messages")
While $iJ < $iCount_j
$oJResp.J = $iJ
$iJ = $iJ + 1
Wend
$i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("messages")
While $i < $iCount_i
$oJResp.I = $i
$source = $oJResp.StringOf("messages[i].source")
$sCode = $oJResp.StringOf("messages[i].code")
$sText = $oJResp.StringOf("messages[i].text")
$i = $i + 1
Wend