unicodeC / CleverTap API / Test Webhook Payload
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.
// {
// "is_test": true,
// "targetId": 1234,
// "key_values": {
// "key": "value"
// },
// "profiles": [
// {
// "Identity": "UserId",
// "Email": "User@user.com",
// "push_token": "Token"
// },
// {
// "Identity": "UserId",
// "Email": "User@user.com",
// "push_token": "Token"
// },
// {
// "Identity": "UserId",
// "Email": "User@user.com",
// "push_token": "Token"
// },
// {
// "Identity": "UserId",
// "Email": "User@user.com",
// "push_token": "Token"
// },
// {
// "Identity": "UserId",
// "Email": "User@user.com",
// "push_token": "Token"
// }
// ]
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateBool(json,L"is_test",TRUE);
CkJsonObjectW_UpdateInt(json,L"targetId",1234);
CkJsonObjectW_UpdateString(json,L"key_values.key",L"value");
CkJsonObjectW_UpdateString(json,L"profiles[0].Identity",L"UserId");
CkJsonObjectW_UpdateString(json,L"profiles[0].Email",L"User@user.com");
CkJsonObjectW_UpdateString(json,L"profiles[0].push_token",L"Token");
CkJsonObjectW_UpdateString(json,L"profiles[1].Identity",L"UserId");
CkJsonObjectW_UpdateString(json,L"profiles[1].Email",L"User@user.com");
CkJsonObjectW_UpdateString(json,L"profiles[1].push_token",L"Token");
CkJsonObjectW_UpdateString(json,L"profiles[2].Identity",L"UserId");
CkJsonObjectW_UpdateString(json,L"profiles[2].Email",L"User@user.com");
CkJsonObjectW_UpdateString(json,L"profiles[2].push_token",L"Token");
CkJsonObjectW_UpdateString(json,L"profiles[3].Identity",L"UserId");
CkJsonObjectW_UpdateString(json,L"profiles[3].Email",L"User@user.com");
CkJsonObjectW_UpdateString(json,L"profiles[3].push_token",L"Token");
CkJsonObjectW_UpdateString(json,L"profiles[4].Identity",L"UserId");
CkJsonObjectW_UpdateString(json,L"profiles[4].Email",L"User@user.com");
CkJsonObjectW_UpdateString(json,L"profiles[4].push_token",L"Token");
CkHttpW_SetRequestHeader(http,L"Content-Type",L"{{type}}");
CkHttpW_SetRequestHeader(http,L"User-Agent",L"{{user-agent}}");
CkHttpW_SetRequestHeader(http,L"Content-Length",L"{{content-length}}");
resp = CkHttpW_PostJson3(http,L"https://domain.com/",L"{{type}}",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: {{type}}"
-H "Content-Length: {{content-length}}"
-H "User-Agent: {{user-agent}}"
-d '{ "is_test" : true , "targetId" : 1234 , "key_values" : { "key" : "value"} , "profiles" : [ { "Identity" : "UserId" , "Email" : "User@user.com" , "push_token" : "Token"} , { "Identity" : "UserId" , "Email" : "User@user.com" , "push_token" : "Token"} , { "Identity" : "UserId" , "Email" : "User@user.com" , "push_token" : "Token"} , { "Identity" : "UserId" , "Email" : "User@user.com" , "push_token" : "Token"} , { "Identity" : "UserId" , "Email" : "User@user.com" , "push_token" : "Token"}]}'
https://domain.com/
Postman Collection Item JSON
{
"name": "Test Webhook Payload",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "{{type}}"
},
{
"key": "Content-Length",
"value": "{{content-length}}"
},
{
"key": "User-Agent",
"value": "{{user-agent}}"
}
],
"body": {
"mode": "raw",
"raw": "{ \"is_test\" : true , \"targetId\" : 1234 , \"key_values\" : { \"key\" : \"value\"} , \"profiles\" : [ { \"Identity\" : \"UserId\" , \"Email\" : \"User@user.com\" , \"push_token\" : \"Token\"} , { \"Identity\" : \"UserId\" , \"Email\" : \"User@user.com\" , \"push_token\" : \"Token\"} , { \"Identity\" : \"UserId\" , \"Email\" : \"User@user.com\" , \"push_token\" : \"Token\"} , { \"Identity\" : \"UserId\" , \"Email\" : \"User@user.com\" , \"push_token\" : \"Token\"} , { \"Identity\" : \"UserId\" , \"Email\" : \"User@user.com\" , \"push_token\" : \"Token\"}]}"
},
"url": {
"raw": ""
}
},
"response": [
]
}