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();
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "status": "completed",
// "partnerStatus": "Inspection Scheduled",
// "referenceNumber": "ORDER_REFERENCE_NUMBER",
// "respondingParty ": {
// "name": "COMPANY_NAME",
// "address": "COMPANY_STREET_ADDRESS",
// "city": "COMPANY_CITY",
// "state": "COMPANY_STATE",
// "postalCode": "COMPANY_ZIP_CODE",
// "pointOfContact": {
// "name": "CONTACT_NAME",
// "role": "CONTACT_ROLE",
// "phone": "CONTACT_PHONE_NUMBER",
// "email": "CONTACT_EMAIL"
// }
// },
// "loanFormat": "application/vnd.plm-2.0.0+json",
// "loan": {
// "propertyAppraisedValueAmount": "1000000"
// },
// "resources": [
// {
// "id": "{{partner_resource_id}}",
// "name": "{{partner_resource_name}}",
// "mimeType": "{{partner_resource_mimeType}}"
// }
// ]
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"status",L"completed");
CkJsonObjectW_UpdateString(json,L"partnerStatus",L"Inspection Scheduled");
CkJsonObjectW_UpdateString(json,L"referenceNumber",L"ORDER_REFERENCE_NUMBER");
CkJsonObjectW_UpdateString(json,L"\"respondingParty \".name",L"COMPANY_NAME");
CkJsonObjectW_UpdateString(json,L"\"respondingParty \".address",L"COMPANY_STREET_ADDRESS");
CkJsonObjectW_UpdateString(json,L"\"respondingParty \".city",L"COMPANY_CITY");
CkJsonObjectW_UpdateString(json,L"\"respondingParty \".state",L"COMPANY_STATE");
CkJsonObjectW_UpdateString(json,L"\"respondingParty \".postalCode",L"COMPANY_ZIP_CODE");
CkJsonObjectW_UpdateString(json,L"\"respondingParty \".pointOfContact.name",L"CONTACT_NAME");
CkJsonObjectW_UpdateString(json,L"\"respondingParty \".pointOfContact.role",L"CONTACT_ROLE");
CkJsonObjectW_UpdateString(json,L"\"respondingParty \".pointOfContact.phone",L"CONTACT_PHONE_NUMBER");
CkJsonObjectW_UpdateString(json,L"\"respondingParty \".pointOfContact.email",L"CONTACT_EMAIL");
CkJsonObjectW_UpdateString(json,L"loanFormat",L"application/vnd.plm-2.0.0+json");
CkJsonObjectW_UpdateString(json,L"loan.propertyAppraisedValueAmount",L"1000000");
CkJsonObjectW_UpdateString(json,L"resources[0].id",L"{{partner_resource_id}}");
CkJsonObjectW_UpdateString(json,L"resources[0].name",L"{{partner_resource_name}}");
CkJsonObjectW_UpdateString(json,L"resources[0].mimeType",L"{{partner_resource_mimeType}}");
CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
// Adds the "Authorization: Bearer {{partner_token}}" header.
CkHttpW_putAuthToken(http,L"{{partner_token}}");
sbRequestBody = CkStringBuilderW_Create();
CkJsonObjectW_EmitSb(json,sbRequestBody);
resp = CkHttpW_PTextSb(http,L"PATCH",L"https://domain.com/",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 PATCH
-H "Content-Type: application/json"
-H "Authorization: Bearer {{partner_token}}"
-d '{
"status": "completed",
"partnerStatus": "Inspection Scheduled",
"referenceNumber": "ORDER_REFERENCE_NUMBER",
"respondingParty ": {
"name": "COMPANY_NAME",
"address": "COMPANY_STREET_ADDRESS",
"city": "COMPANY_CITY",
"state": "COMPANY_STATE",
"postalCode": "COMPANY_ZIP_CODE",
"pointOfContact": {
"name": "CONTACT_NAME",
"role": "CONTACT_ROLE",
"phone": "CONTACT_PHONE_NUMBER",
"email": "CONTACT_EMAIL"
}
},
"loanFormat": "application/vnd.plm-2.0.0+json",
"loan": {
"propertyAppraisedValueAmount": "1000000"
},
"resources": [
{
"id": "{{partner_resource_id}}",
"name": "{{partner_resource_name}}",
"mimeType": "{{partner_resource_mimeType}}"
}
]
}'
https://domain.com/
Postman Collection Item JSON
{
"name": "[Partner] Send Completed Response",
"_postman_id": "476af59a-fb96-4126-8f16-4a59f0f324e1",
"request": {
"method": "PATCH",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "Authorization",
"value": "Bearer {{partner_token}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"status\": \"completed\",\n \"partnerStatus\": \"Inspection Scheduled\",\n \"referenceNumber\": \"ORDER_REFERENCE_NUMBER\",\n \"respondingParty \": {\n \"name\": \"COMPANY_NAME\",\n \"address\": \"COMPANY_STREET_ADDRESS\",\n \"city\": \"COMPANY_CITY\",\n \"state\": \"COMPANY_STATE\",\n \"postalCode\": \"COMPANY_ZIP_CODE\",\n \"pointOfContact\": {\n \"name\": \"CONTACT_NAME\",\n \"role\": \"CONTACT_ROLE\",\n \"phone\": \"CONTACT_PHONE_NUMBER\",\n \"email\": \"CONTACT_EMAIL\"\n }\n },\n \"loanFormat\": \"application/vnd.plm-2.0.0+json\",\n \"loan\": {\n \"propertyAppraisedValueAmount\": \"1000000\"\n },\n \"resources\": [\n {\n \t\"id\": \"{{partner_resource_id}}\",\n \t\"name\": \"{{partner_resource_name}}\",\n \t\"mimeType\": \"{{partner_resource_mimeType}}\"\n }\n ]\n}"
},
"url": "{{api_host}}/partner/v2/transactions/{{transaction_id}}/response"
},
"response": [
]
}