unicodeCpp / CleverTap API / Test Webhook Payload
Back to Collection Items
#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkHttpResponseW.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttpW http;
bool success;
// 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"
// }
// ]
// }
CkJsonObjectW json;
json.UpdateBool(L"is_test",true);
json.UpdateInt(L"targetId",1234);
json.UpdateString(L"key_values.key",L"value");
json.UpdateString(L"profiles[0].Identity",L"UserId");
json.UpdateString(L"profiles[0].Email",L"User@user.com");
json.UpdateString(L"profiles[0].push_token",L"Token");
json.UpdateString(L"profiles[1].Identity",L"UserId");
json.UpdateString(L"profiles[1].Email",L"User@user.com");
json.UpdateString(L"profiles[1].push_token",L"Token");
json.UpdateString(L"profiles[2].Identity",L"UserId");
json.UpdateString(L"profiles[2].Email",L"User@user.com");
json.UpdateString(L"profiles[2].push_token",L"Token");
json.UpdateString(L"profiles[3].Identity",L"UserId");
json.UpdateString(L"profiles[3].Email",L"User@user.com");
json.UpdateString(L"profiles[3].push_token",L"Token");
json.UpdateString(L"profiles[4].Identity",L"UserId");
json.UpdateString(L"profiles[4].Email",L"User@user.com");
json.UpdateString(L"profiles[4].push_token",L"Token");
http.SetRequestHeader(L"Content-Type",L"{{type}}");
http.SetRequestHeader(L"User-Agent",L"{{user-agent}}");
http.SetRequestHeader(L"Content-Length",L"{{content-length}}");
CkHttpResponseW *resp = http.PostJson3(L"https://domain.com/",L"{{type}}",json);
if (http.get_LastMethodSuccess() == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
wprintf(L"%d\n",resp->get_StatusCode());
wprintf(L"%s\n",resp->bodyStr());
delete resp;
}
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": [
]
}