unicodeC / Bond APIs / update webhook
Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW json;
HCkStringBuilderW sbRequestBody;
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.
// {
// "action": "add_events",
// "events": [
// "kyc.verification.success",
// "kyc.verification.failure",
// "kyc.verification.error",
// "kyc.verification.timeout",
// "kyc.verification.kba"
// ],
// "callback_url": "",
// "description": ""
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"action",L"add_events");
CkJsonObjectW_UpdateString(json,L"events[0]",L"kyc.verification.success");
CkJsonObjectW_UpdateString(json,L"events[1]",L"kyc.verification.failure");
CkJsonObjectW_UpdateString(json,L"events[2]",L"kyc.verification.error");
CkJsonObjectW_UpdateString(json,L"events[3]",L"kyc.verification.timeout");
CkJsonObjectW_UpdateString(json,L"events[4]",L"kyc.verification.kba");
CkJsonObjectW_UpdateString(json,L"callback_url",L"");
CkJsonObjectW_UpdateString(json,L"description",L"");
CkHttpW_SetRequestHeader(http,L"Identity",L"{{identity}}");
CkHttpW_SetRequestHeader(http,L"Authorization",L"{{authorization}}");
sbRequestBody = CkStringBuilderW_Create();
CkJsonObjectW_EmitSb(json,sbRequestBody);
resp = CkHttpW_PTextSb(http,L"PATCH",L"https://{{environment}}.bond.tech/api/v0/webhooks/:webhook_id",sbRequestBody,L"utf-8",L"application/json",FALSE,FALSE);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
return;
}
wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(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}"
}
]
}