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
(Visual FoxPro) 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/
LOCAL loHttp LOCAL lnSuccess LOCAL loJson LOCAL loResp LOCAL loSbResponseBody LOCAL loJResp LOCAL lnRespStatusCode * This example assumes the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http') loHttp = CreateObject('Chilkat.Http') * 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" * } * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJson = CreateObject('Chilkat.JsonObject') loJson.UpdateString("to_address.city","San Francisco") loJson.UpdateString("to_address.company","Shippo") loJson.UpdateString("to_address.country","US") loJson.UpdateString("to_address.email","shippotle@goshippo.com") loJson.UpdateString("to_address.name","Mr Hippo") loJson.UpdateString("to_address.phone","15553419393") loJson.UpdateString("to_address.state","CA") loJson.UpdateString("to_address.street1","215 Clayton St.") loJson.UpdateString("to_address.zip","94117") loJson.UpdateInt("line_items[0].quantity",1) loJson.UpdateString("line_items[0].sku","HM-123") loJson.UpdateString("line_items[0].title","Hippo Magazines") loJson.UpdateString("line_items[0].total_price","12.10") loJson.UpdateString("line_items[0].currency","USD") loJson.UpdateString("line_items[0].weight","0.40") loJson.UpdateString("line_items[0].weight_unit","lb") loJson.UpdateString("placed_at","2016-09-23T01:28:12Z") loJson.UpdateString("order_number","#1068") loJson.UpdateString("order_status","PAID") loJson.UpdateString("shipping_cost","12.83") loJson.UpdateString("shipping_cost_currency","USD") loJson.UpdateString("shipping_method","USPS First Class Package") loJson.UpdateString("subtotal_price","12.10") loJson.UpdateString("total_price","24.93") loJson.UpdateString("total_tax","0.00") loJson.UpdateString("currency","USD") loJson.UpdateString("weight","0.40") loJson.UpdateString("weight_unit","lb") loHttp.SetRequestHeader("Authorization","ShippoToken <API_Token>") loHttp.SetRequestHeader("Content-Type","application/json") loResp = loHttp.PostJson3("https://api.goshippo.com/orders/","application/json",loJson) IF (loHttp.LastMethodSuccess = 0) THEN ? loHttp.LastErrorText RELEASE loHttp RELEASE loJson CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbResponseBody = CreateObject('Chilkat.StringBuilder') loResp.GetBodySb(loSbResponseBody) * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJResp = CreateObject('Chilkat.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) * {} * Sample code for parsing the JSON response... * Use the following online tool to generate parsing code from sample JSON: * Generate Parsing Code from JSON RELEASE loHttp RELEASE loJson RELEASE loSbResponseBody RELEASE loJResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.