Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(Excel) Shippo Create an OrderDemonstrates how to create an order with all the information about your order by sending a POST request to the orders endpoint. For more information, see https://goshippo.com/docs/orders/
' This example assumes the Chilkat API to have been previously unlocked. ' See Global Unlock Sample for sample code. Dim http As Chilkat.Http Set http = Chilkat.NewHttp ' Implements the following CURL command: ' curl https://api.goshippo.com/orders/ \ ' -H "Authorization: ShippoToken <API_Token>" \ ' -H "Content-Type: application/json" \ ' -d '{ ' "to_address": { ' "city": "San Francisco", ' "company": "Shippo", ' "country": "US", ' "email": "shippotle@goshippo.com", ' "name": "Mr Hippo", ' "phone": "15553419393", ' "state": "CA", ' "street1": "215 Clayton St.", ' "zip": "94117" ' }, ' "line_items": [ ' { ' "quantity": 1, ' "sku": "HM-123", ' "title": "Hippo Magazines", ' "total_price": "12.10", ' "currency": "USD", ' "weight": "0.40", ' "weight_unit": "lb" ' } ' ], ' "placed_at": "2016-09-23T01:28:12Z", ' "order_number": "#1068", ' "order_status": "PAID", ' "shipping_cost": "12.83", ' "shipping_cost_currency": "USD", ' "shipping_method": "USPS First Class Package", ' "subtotal_price": "12.10", ' "total_price": "24.93", ' "total_tax": "0.00", ' "currency": "USD", ' "weight": "0.40", ' "weight_unit": "lb" ' }' ' Use this online tool to generate code from sample JSON: ' Generate Code to Create JSON ' The following JSON is sent in the request body. ' { ' "to_address": { ' "city": "San Francisco", ' "company": "Shippo", ' "country": "US", ' "email": "shippotle@goshippo.com", ' "name": "Mr Hippo", ' "phone": "15553419393", ' "state": "CA", ' "street1": "215 Clayton St.", ' "zip": "94117" ' }, ' "line_items": [ ' { ' "quantity": 1, ' "sku": "HM-123", ' "title": "Hippo Magazines", ' "total_price": "12.10", ' "currency": "USD", ' "weight": "0.40", ' "weight_unit": "lb" ' } ' ], ' "placed_at": "2016-09-23T01:28:12Z", ' "order_number": "#1068", ' "order_status": "PAID", ' "shipping_cost": "12.83", ' "shipping_cost_currency": "USD", ' "shipping_method": "USPS First Class Package", ' "subtotal_price": "12.10", ' "total_price": "24.93", ' "total_tax": "0.00", ' "currency": "USD", ' "weight": "0.40", ' "weight_unit": "lb" ' } Dim json As Chilkat.JsonObject Set json = Chilkat.NewJsonObject success = json.UpdateString("to_address.city","San Francisco") success = json.UpdateString("to_address.company","Shippo") success = json.UpdateString("to_address.country","US") success = json.UpdateString("to_address.email","shippotle@goshippo.com") success = json.UpdateString("to_address.name","Mr Hippo") success = json.UpdateString("to_address.phone","15553419393") success = json.UpdateString("to_address.state","CA") success = json.UpdateString("to_address.street1","215 Clayton St.") success = json.UpdateString("to_address.zip","94117") success = json.UpdateInt("line_items[0].quantity",1) success = json.UpdateString("line_items[0].sku","HM-123") success = json.UpdateString("line_items[0].title","Hippo Magazines") success = json.UpdateString("line_items[0].total_price","12.10") success = json.UpdateString("line_items[0].currency","USD") success = json.UpdateString("line_items[0].weight","0.40") success = json.UpdateString("line_items[0].weight_unit","lb") success = json.UpdateString("placed_at","2016-09-23T01:28:12Z") success = json.UpdateString("order_number","#1068") success = json.UpdateString("order_status","PAID") success = json.UpdateString("shipping_cost","12.83") success = json.UpdateString("shipping_cost_currency","USD") success = json.UpdateString("shipping_method","USPS First Class Package") success = json.UpdateString("subtotal_price","12.10") success = json.UpdateString("total_price","24.93") success = json.UpdateString("total_tax","0.00") success = json.UpdateString("currency","USD") success = json.UpdateString("weight","0.40") success = json.UpdateString("weight_unit","lb") http.SetRequestHeader "Authorization","ShippoToken <API_Token>" http.SetRequestHeader "Content-Type","application/json" Set resp = http.PostJson3("https://api.goshippo.com/orders/","application/json",json) If (http.LastMethodSuccess = False) Then Debug.Print http.LastErrorText Exit Sub End If Dim sbResponseBody As Chilkat.StringBuilder Set sbResponseBody = Chilkat.NewStringBuilder success = resp.GetBodySb(sbResponseBody) Dim jResp As Chilkat.JsonObject Set jResp = Chilkat.NewJsonObject success = jResp.LoadSb(sbResponseBody) jResp.EmitCompact = False Debug.Print "Response Body:" Debug.Print jResp.Emit() 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) ' {} ' Sample code for parsing the JSON response... ' Use the following online tool to generate parsing code from sample JSON: ' Generate Parsing Code from JSON |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.