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.
// {
// "brandCompany": "sample string 1",
// "brandId": "sample string 2",
// "brandName": "sample string 3",
// "colors": [
// {}
// ],
// "isOverridingCompanyName": "sample string 4",
// "isSendingDefault": "sample string 5",
// "isSigningDefault": "sample string 6",
// "landingPages": [
// {}
// ],
// "links": [
// {
// "linkType": "sample string 1",
// "urlOrMailTo": "sample string 2",
// "linkText": "sample string 3",
// "showLink": "sample string 4"
// }
// ],
// "emailContent": [
// {
// "emailContentType": "sample string 1",
// "content": "sample string 2",
// "emailToLink": "sample string 3",
// "linkText": "sample string 4"
// }
// ],
// "logos": {
// "primary": "sample string 1",
// "secondary": "sample string 2",
// "email": "sample string 3"
// },
// "resources": {
// "email": "sample string 1",
// "sending": "sample string 2",
// "signing": "sample string 3",
// "signingCaptive": "sample string 4"
// }
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"brandCompany",L"sample string 1");
CkJsonObjectW_UpdateString(json,L"brandId",L"sample string 2");
CkJsonObjectW_UpdateString(json,L"brandName",L"sample string 3");
CkJsonObjectW_UpdateString(json,L"isOverridingCompanyName",L"sample string 4");
CkJsonObjectW_UpdateString(json,L"isSendingDefault",L"sample string 5");
CkJsonObjectW_UpdateString(json,L"isSigningDefault",L"sample string 6");
CkJsonObjectW_UpdateString(json,L"links[0].linkType",L"sample string 1");
CkJsonObjectW_UpdateString(json,L"links[0].urlOrMailTo",L"sample string 2");
CkJsonObjectW_UpdateString(json,L"links[0].linkText",L"sample string 3");
CkJsonObjectW_UpdateString(json,L"links[0].showLink",L"sample string 4");
CkJsonObjectW_UpdateString(json,L"emailContent[0].emailContentType",L"sample string 1");
CkJsonObjectW_UpdateString(json,L"emailContent[0].content",L"sample string 2");
CkJsonObjectW_UpdateString(json,L"emailContent[0].emailToLink",L"sample string 3");
CkJsonObjectW_UpdateString(json,L"emailContent[0].linkText",L"sample string 4");
CkJsonObjectW_UpdateString(json,L"logos.primary",L"sample string 1");
CkJsonObjectW_UpdateString(json,L"logos.secondary",L"sample string 2");
CkJsonObjectW_UpdateString(json,L"logos.email",L"sample string 3");
CkJsonObjectW_UpdateString(json,L"resources.email",L"sample string 1");
CkJsonObjectW_UpdateString(json,L"resources.sending",L"sample string 2");
CkJsonObjectW_UpdateString(json,L"resources.signing",L"sample string 3");
CkJsonObjectW_UpdateString(json,L"resources.signingCaptive",L"sample string 4");
// Adds the "Authorization: Bearer {{accessToken}}" header.
CkHttpW_putAuthToken(http,L"{{accessToken}}");
CkHttpW_SetRequestHeader(http,L"Accept",L"application/json");
sbRequestBody = CkStringBuilderW_Create();
CkJsonObjectW_EmitSb(json,sbRequestBody);
resp = CkHttpW_PTextSb(http,L"PUT",L"https://domain.com/v2.1/accounts/{{accountId}}/brands/{{brandId}}",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 PUT
-H "Accept: application/json"
-H "Authorization: Bearer {{accessToken}}"
-d '{
"brandCompany": "sample string 1",
"brandId": "sample string 2",
"brandName": "sample string 3",
"colors": [
{}
],
"isOverridingCompanyName": "sample string 4",
"isSendingDefault": "sample string 5",
"isSigningDefault": "sample string 6",
"landingPages": [
{}
],
"links": [
{
"linkType": "sample string 1",
"urlOrMailTo": "sample string 2",
"linkText": "sample string 3",
"showLink": "sample string 4"
}
],
"emailContent": [
{
"emailContentType": "sample string 1",
"content": "sample string 2",
"emailToLink": "sample string 3",
"linkText": "sample string 4"
}
],
"logos": {
"primary": "sample string 1",
"secondary": "sample string 2",
"email": "sample string 3"
},
"resources": {
"email": "sample string 1",
"sending": "sample string 2",
"signing": "sample string 3",
"signingCaptive": "sample string 4"
}
}'
https://domain.com/v2.1/accounts/{{accountId}}/brands/{{brandId}}
Postman Collection Item JSON
{
"name": "Updates an existing brand.",
"request": {
"method": "PUT",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{accessToken}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"brandCompany\": \"sample string 1\",\n \"brandId\": \"sample string 2\",\n \"brandName\": \"sample string 3\",\n \"colors\": [\n {}\n ],\n \"isOverridingCompanyName\": \"sample string 4\",\n \"isSendingDefault\": \"sample string 5\",\n \"isSigningDefault\": \"sample string 6\",\n \"landingPages\": [\n {}\n ],\n \"links\": [\n {\n \"linkType\": \"sample string 1\",\n \"urlOrMailTo\": \"sample string 2\",\n \"linkText\": \"sample string 3\",\n \"showLink\": \"sample string 4\"\n }\n ],\n \"emailContent\": [\n {\n \"emailContentType\": \"sample string 1\",\n \"content\": \"sample string 2\",\n \"emailToLink\": \"sample string 3\",\n \"linkText\": \"sample string 4\"\n }\n ],\n \"logos\": {\n \"primary\": \"sample string 1\",\n \"secondary\": \"sample string 2\",\n \"email\": \"sample string 3\"\n },\n \"resources\": {\n \"email\": \"sample string 1\",\n \"sending\": \"sample string 2\",\n \"signing\": \"sample string 3\",\n \"signingCaptive\": \"sample string 4\"\n }\n}"
},
"url": {
"raw": "{{baseUrl}}/v2.1/accounts/{{accountId}}/brands/{{brandId}}",
"host": [
"{{baseUrl}}"
],
"path": [
"v2.1",
"accounts",
"{{accountId}}",
"brands",
"{{brandId}}"
],
"variable": [
{
"key": "accountId",
"value": "{{accountId}}",
"type": "string"
},
{
"key": "brandId",
"value": "{{brandId}}",
"type": "string"
}
]
}
},
"response": [
]
}