unicodeC / Bond APIs / create customer
Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW json;
HCkHttpResponseW resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "brand_person_id": "832be8a2-7f5e-4d92-b1dd-b5923cc57fe7",
// "dob": "1925-10-23",
// "first_name": "James",
// "middle_name": "William",
// "last_name": "Bond",
// "addresses": [
// {
// "address_type": "PHYSICAL",
// "street": "123 Market St",
// "city": "San Francisco",
// "state": "CA",
// "zip_code": "12345-1111",
// "country": "US",
// "is_primary": true
// }
// ]
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"brand_person_id",L"832be8a2-7f5e-4d92-b1dd-b5923cc57fe7");
CkJsonObjectW_UpdateString(json,L"dob",L"1925-10-23");
CkJsonObjectW_UpdateString(json,L"first_name",L"James");
CkJsonObjectW_UpdateString(json,L"middle_name",L"William");
CkJsonObjectW_UpdateString(json,L"last_name",L"Bond");
CkJsonObjectW_UpdateString(json,L"addresses[0].address_type",L"PHYSICAL");
CkJsonObjectW_UpdateString(json,L"addresses[0].street",L"123 Market St");
CkJsonObjectW_UpdateString(json,L"addresses[0].city",L"San Francisco");
CkJsonObjectW_UpdateString(json,L"addresses[0].state",L"CA");
CkJsonObjectW_UpdateString(json,L"addresses[0].zip_code",L"12345-1111");
CkJsonObjectW_UpdateString(json,L"addresses[0].country",L"US");
CkJsonObjectW_UpdateBool(json,L"addresses[0].is_primary",TRUE);
CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
CkHttpW_SetRequestHeader(http,L"Authorization",L"{{authorization}}");
CkHttpW_SetRequestHeader(http,L"Identity",L"{{identity}}");
resp = CkHttpW_PostJson3(http,L"https://{{environment}}.bond.tech/api/v0/customers",L"application/json",json);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
return;
}
wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
}
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Authorization: {{authorization}}"
-H "Identity: {{identity}}"
-d '{
"brand_person_id": "832be8a2-7f5e-4d92-b1dd-b5923cc57fe7",
"dob": "1925-10-23",
"first_name": "James",
"middle_name":"William",
"last_name": "Bond",
"addresses": [
{
"address_type": "PHYSICAL",
"street": "123 Market St",
"city": "San Francisco",
"state": "CA",
"zip_code": "12345-1111",
"country": "US",
"is_primary": true
}
]
}'
https://{{environment}}.bond.tech/api/v0/customers
Postman Collection Item JSON
{
"name": "create customer",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = pm.response.json();",
"pm.collectionVariables.set(\"customer_id\", jsonData.customer_id)"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
},
{
"key": "Authorization",
"type": "text",
"value": "{{authorization}}"
},
{
"key": "Identity",
"type": "text",
"value": "{{identity}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"brand_person_id\": \"832be8a2-7f5e-4d92-b1dd-b5923cc57fe7\",\n \"dob\": \"1925-10-23\",\n \"first_name\": \"James\",\n \"middle_name\":\"William\",\n \"last_name\": \"Bond\",\n \"addresses\": [\n {\n \"address_type\": \"PHYSICAL\",\n \"street\": \"123 Market St\",\n \"city\": \"San Francisco\",\n \"state\": \"CA\",\n \"zip_code\": \"12345-1111\",\n \"country\": \"US\",\n \"is_primary\": true\n }\n ]\n}"
},
"url": {
"raw": "https://{{environment}}.bond.tech/api/v0/customers",
"protocol": "https",
"host": [
"{{environment}}",
"bond",
"tech"
],
"path": [
"api",
"v0",
"customers"
]
},
"description": "Add Card financial Core"
},
"response": [
{
"name": "example",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "Authorization",
"type": "text",
"value": "{{authorization}}"
},
{
"key": "Identity",
"type": "text",
"value": "{{identity}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"brand_person_id\": \"2f55fd85-f411-491e-86a2-558336d6c2a5\",\n \"dob\": \"1992-12-01\",\n \"first_name\": \"Johnny\",\n \"middle_name\":\"William\",\n \"last_name\": \"Carson\",\n \"addresses\": [\n {\n \"address_type\": \"PHYSICAL\",\n \"street\": \"123 Market St\",\n \"city\": \"San Fransico\",\n \"state\": \"CA\",\n \"zip_code\": \"12345-1111\",\n \"country\": \"US\",\n \"is_primary\": true\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{environment}}.bond.tech/api/v0/customers",
"protocol": "https",
"host": [
"{{environment}}",
"bond",
"tech"
],
"path": [
"api",
"v0",
"customers"
]
}
},
"_postman_previewlanguage": null,
"header": null,
"cookie": [
],
"body": null
}
]
}