DataFlex / CleverTap API / Test Webhook Payload
Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vJson
Handle hoJson
Variant vResp
Handle hoResp
String sTemp1
Integer iTemp1
Boolean bTemp1
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// 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"
// }
// ]
// }
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateBool Of hoJson "is_test" True To iSuccess
Get ComUpdateInt Of hoJson "targetId" 1234 To iSuccess
Get ComUpdateString Of hoJson "key_values.key" "value" To iSuccess
Get ComUpdateString Of hoJson "profiles[0].Identity" "UserId" To iSuccess
Get ComUpdateString Of hoJson "profiles[0].Email" "User@user.com" To iSuccess
Get ComUpdateString Of hoJson "profiles[0].push_token" "Token" To iSuccess
Get ComUpdateString Of hoJson "profiles[1].Identity" "UserId" To iSuccess
Get ComUpdateString Of hoJson "profiles[1].Email" "User@user.com" To iSuccess
Get ComUpdateString Of hoJson "profiles[1].push_token" "Token" To iSuccess
Get ComUpdateString Of hoJson "profiles[2].Identity" "UserId" To iSuccess
Get ComUpdateString Of hoJson "profiles[2].Email" "User@user.com" To iSuccess
Get ComUpdateString Of hoJson "profiles[2].push_token" "Token" To iSuccess
Get ComUpdateString Of hoJson "profiles[3].Identity" "UserId" To iSuccess
Get ComUpdateString Of hoJson "profiles[3].Email" "User@user.com" To iSuccess
Get ComUpdateString Of hoJson "profiles[3].push_token" "Token" To iSuccess
Get ComUpdateString Of hoJson "profiles[4].Identity" "UserId" To iSuccess
Get ComUpdateString Of hoJson "profiles[4].Email" "User@user.com" To iSuccess
Get ComUpdateString Of hoJson "profiles[4].push_token" "Token" To iSuccess
Send ComSetRequestHeader To hoHttp "Content-Type" "{{type}}"
Send ComSetRequestHeader To hoHttp "User-Agent" "{{user-agent}}"
Send ComSetRequestHeader To hoHttp "Content-Length" "{{content-length}}"
Get pvComObject of hoJson to vJson
Get ComPostJson3 Of hoHttp "https://domain.com/" "{{type}}" vJson To vResp
If (IsComObject(vResp)) Begin
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
Set pvComObject Of hoResp To vResp
End
Get ComLastMethodSuccess Of hoHttp To bTemp1
If (bTemp1 = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComStatusCode Of hoResp To iTemp1
Showln iTemp1
Get ComBodyStr Of hoResp To sTemp1
Showln sTemp1
Send Destroy of hoResp
End_Procedure
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": [
]
}