PowerBuilder / CleverTap API / Test Webhook Payload
Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Json
oleobject loo_Resp
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
// 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"
// }
// ]
// }
loo_Json = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
loo_Json.UpdateBool("is_test",1)
loo_Json.UpdateInt("targetId",1234)
loo_Json.UpdateString("key_values.key","value")
loo_Json.UpdateString("profiles[0].Identity","UserId")
loo_Json.UpdateString("profiles[0].Email","User@user.com")
loo_Json.UpdateString("profiles[0].push_token","Token")
loo_Json.UpdateString("profiles[1].Identity","UserId")
loo_Json.UpdateString("profiles[1].Email","User@user.com")
loo_Json.UpdateString("profiles[1].push_token","Token")
loo_Json.UpdateString("profiles[2].Identity","UserId")
loo_Json.UpdateString("profiles[2].Email","User@user.com")
loo_Json.UpdateString("profiles[2].push_token","Token")
loo_Json.UpdateString("profiles[3].Identity","UserId")
loo_Json.UpdateString("profiles[3].Email","User@user.com")
loo_Json.UpdateString("profiles[3].push_token","Token")
loo_Json.UpdateString("profiles[4].Identity","UserId")
loo_Json.UpdateString("profiles[4].Email","User@user.com")
loo_Json.UpdateString("profiles[4].push_token","Token")
loo_Http.SetRequestHeader("Content-Type","{{type}}")
loo_Http.SetRequestHeader("User-Agent","{{user-agent}}")
loo_Http.SetRequestHeader("Content-Length","{{content-length}}")
loo_Resp = loo_Http.PostJson3("https://domain.com/","{{type}}",loo_Json)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Json
return
end if
Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr
destroy loo_Resp
destroy loo_Http
destroy loo_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": [
]
}