Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW json;
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.
// {
// "FullName": "MyEventRelay",
// "Metadata": {
// "eventChannel": "Carbon_Comparison_Channel__chn",
// "destinationResourceName": "callout:MyNamedCredential",
// "label": "My Event Relay",
// "relayOption": "{\"ReplayRecovery\":\"LATEST\"}"
// }
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"FullName",L"MyEventRelay");
CkJsonObjectW_UpdateString(json,L"Metadata.eventChannel",L"Carbon_Comparison_Channel__chn");
CkJsonObjectW_UpdateString(json,L"Metadata.destinationResourceName",L"callout:MyNamedCredential");
CkJsonObjectW_UpdateString(json,L"Metadata.label",L"My Event Relay");
CkJsonObjectW_UpdateString(json,L"Metadata.relayOption",L"{\"ReplayRecovery\":\"LATEST\"}");
// Adds the "Authorization: Bearer <access_token>" header.
CkHttpW_putAuthToken(http,L"<access_token>");
resp = CkHttpW_PostJson3(http,L"https://domain.com/services/data/v{{version}}/tooling/sobjects/EventRelayConfig/",L"application/json",json);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
return;
}
wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
}
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-d '{
"FullName": "MyEventRelay",
"Metadata": {
"eventChannel": "Carbon_Comparison_Channel__chn",
"destinationResourceName": "callout:MyNamedCredential",
"label": "My Event Relay",
"relayOption": "{\"ReplayRecovery\":\"LATEST\"}"
}
}'
https://domain.com/services/data/v{{version}}/tooling/sobjects/EventRelayConfig/
Postman Collection Item JSON
{
"name": "Create event relay",
"protocolProfileBehavior": {
"strictSSL": false
},
"request": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"FullName\": \"MyEventRelay\",\n \"Metadata\": {\n \"eventChannel\": \"Carbon_Comparison_Channel__chn\",\n \"destinationResourceName\": \"callout:MyNamedCredential\",\n \"label\": \"My Event Relay\",\n \"relayOption\": \"{\\\"ReplayRecovery\\\":\\\"LATEST\\\"}\"\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/tooling/sobjects/EventRelayConfig/",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"tooling",
"sobjects",
"EventRelayConfig",
""
]
}
},
"response": [
]
}