Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW json;
HCkStringBuilderW sbRequestBody;
HCkHttpResponseW resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
CkHttpW_putBasicAuth(http,TRUE);
CkHttpW_putLogin(http,L"100100248");
CkHttpW_putPassword(http,L"117f3fe5a01a0e400f3e4782baf8ffa43a9d21e9217a15f50d545bc72480d081ecaecc1d6a42ac7a785b7437232bd4cf62dbee679b78a75a3892547059018f9b");
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "shippedAt": "2015-01-01T00:00:00Z",
// "name": "CourierPost",
// "tracking": "AA999999999AA",
// "priority": "STANDARD"
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"shippedAt",L"2015-01-01T00:00:00Z");
CkJsonObjectW_UpdateString(json,L"name",L"CourierPost");
CkJsonObjectW_UpdateString(json,L"tracking",L"AA999999999AA");
CkJsonObjectW_UpdateString(json,L"priority",L"STANDARD");
CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
CkHttpW_SetRequestHeader(http,L"Accept",L"application/json");
sbRequestBody = CkStringBuilderW_Create();
CkJsonObjectW_EmitSb(json,sbRequestBody);
resp = CkHttpW_PTextSb(http,L"PUT",L"https://api.us-sandbox.afterpay.com/v2/payments/{{id}}/courier",sbRequestBody,L"utf-8",L"application/json",FALSE,FALSE);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
return;
}
wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
}
Curl Command
curl -X PUT
-u '100100248:117f3fe5a01a0e400f3e4782baf8ffa43a9d21e9217a15f50d545bc72480d081ecaecc1d6a42ac7a785b7437232bd4cf62dbee679b78a75a3892547059018f9b'
-H "Accept: application/json"
-H "Content-Type: application/json"
-d '{
"shippedAt": "2015-01-01T00:00:00Z",
"name": "CourierPost",
"tracking": "AA999999999AA",
"priority": "STANDARD"
}'
https://api.us-sandbox.afterpay.com/v2/payments/{{id}}/courier
Postman Collection Item JSON
{
"name": "Update Shipping Courier",
"event": [
{
"listen": "test",
"script": {
"id": "298e1176-40a1-40ea-adae-d417963f228f",
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "PUT",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"shippedAt\": \"2015-01-01T00:00:00Z\",\n\t\"name\": \"CourierPost\",\n\t\"tracking\": \"AA999999999AA\",\n\t\"priority\": \"STANDARD\"\n}"
},
"url": {
"raw": "https://api.us-sandbox.afterpay.com/v2/payments/{{id}}/courier",
"protocol": "https",
"host": [
"api",
"us-sandbox",
"afterpay",
"com"
],
"path": [
"v2",
"payments",
"{{id}}",
"courier"
]
},
"description": "This resource updates a payment with new shipping courier information. The Afterpay customer support team utilise the shipping courier information when enquiring on the outcome of an order."
},
"response": [
]
}