PowerBuilder / Bond APIs / update webhook
Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Json
oleobject loo_SbRequestBody
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.
// {
// "action": "add_events",
// "events": [
// "kyc.verification.success",
// "kyc.verification.failure",
// "kyc.verification.error",
// "kyc.verification.timeout",
// "kyc.verification.kba"
// ],
// "callback_url": "",
// "description": ""
// }
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.UpdateString("action","add_events")
loo_Json.UpdateString("events[0]","kyc.verification.success")
loo_Json.UpdateString("events[1]","kyc.verification.failure")
loo_Json.UpdateString("events[2]","kyc.verification.error")
loo_Json.UpdateString("events[3]","kyc.verification.timeout")
loo_Json.UpdateString("events[4]","kyc.verification.kba")
loo_Json.UpdateString("callback_url","")
loo_Json.UpdateString("description","")
loo_Http.SetRequestHeader("Identity","{{identity}}")
loo_Http.SetRequestHeader("Authorization","{{authorization}}")
loo_SbRequestBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbRequestBody.ConnectToNewObject("Chilkat.StringBuilder")
loo_Json.EmitSb(loo_SbRequestBody)
loo_Resp = loo_Http.PTextSb("PATCH","https://{{environment}}.bond.tech/api/v0/webhooks/:webhook_id",loo_SbRequestBody,"utf-8","application/json",0,0)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Json
destroy loo_SbRequestBody
return
end if
Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr
destroy loo_Resp
destroy loo_Http
destroy loo_Json
destroy loo_SbRequestBody
Curl Command
curl -X PATCH
-H "Identity: {{identity}}"
-H "Authorization: {{authorization}}"
-d '{
"action": "add_events",
"events": [
"kyc.verification.success",
"kyc.verification.failure",
"kyc.verification.error",
"kyc.verification.timeout",
"kyc.verification.kba"
],
"callback_url": "",
"description": ""
}'
https://{{environment}}.bond.tech/api/v0/webhooks/:webhook_id
Postman Collection Item JSON
{
"name": "update webhook",
"request": {
"method": "PATCH",
"header": [
{
"key": "Identity",
"value": "{{identity}}",
"type": "text"
},
{
"key": "Authorization",
"value": "{{authorization}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"action\": \"add_events\",\n \"events\": [\n \"kyc.verification.success\",\n \"kyc.verification.failure\",\n \"kyc.verification.error\",\n \"kyc.verification.timeout\",\n \"kyc.verification.kba\"\n ],\n \"callback_url\": \"\",\n \"description\": \"\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{environment}}.bond.tech/api/v0/webhooks/:webhook_id",
"protocol": "https",
"host": [
"{{environment}}",
"bond",
"tech"
],
"path": [
"api",
"v0",
"webhooks",
":webhook_id"
],
"variable": [
{
"key": "webhook_id",
"value": null
}
]
}
},
"response": [
{
"name": "example",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Identity",
"value": "{{identity}}",
"type": "text"
},
{
"key": "Authorization",
"value": "{{authorization}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"action\": \"add_events\",\n \"events\": [\n \"kyc.verification.success\",\n \"kyc.verification.failure\",\n \"kyc.verification.error\",\n \"kyc.verification.timeout\",\n \"kyc.verification.kba\"\n ],\n \"callback_url\": \"http://bond.tech\",\n \"description\": \"KYC Event listener\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{environment}}.bond.tech/api/v0/webhooks/:webhook_id",
"protocol": "https",
"host": [
"{{environment}}",
"bond",
"tech"
],
"path": [
"api",
"v0",
"webhooks",
":webhook_id"
],
"variable": [
{
"key": "webhook_id",
"value": null
}
]
}
},
"_postman_previewlanguage": "json",
"header": null,
"cookie": [
],
"body": "{\n \"date_created\": \"2020-11-17T11:13:06.568119\",\n \"webhook_id\": \"522e9ec7-b17d-4d92-8270-c2e1741dd6e0\",\n \"callback_url\": \"https://hostname.com/webhook/route\",\n \"description\": \"KYC state changes.\",\n \"events\": [\n \"kyc.verification.success\",\n \"kyc.verification.failure\",\n \"kyc.verification.kba\",\n \"kyc.verification.error\",\n \"kyc.verification.timeout\"\n ],\n \"status\": \"enabled\",\n \"secret\": \"whsec_XqTEJtniwuEhp0A1c1cTJNsmpR/qgOfB\"\n}"
}
]
}