unicodeCpp / Support API / Create Brand
Back to Collection Items
#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkHttpResponseW.h>
#include <CkStringBuilderW.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttpW http;
bool success;
http.put_BasicAuth(true);
http.put_Login(L"login");
http.put_Password(L"password");
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "brand": {
// "name": "<string>",
// "subdomain": "<string>",
// "active": "<boolean>",
// "brand_url": "<string>",
// "created_at": "<dateTime>",
// "default": "<boolean>",
// "has_help_center": "<boolean>",
// "help_center_state": "enabled",
// "host_mapping": "<string>",
// "id": "<integer>",
// "is_deleted": "<boolean>",
// "logo": {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>",
// "thumbnails": [
// {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>"
// },
// {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>"
// }
// ]
// },
// "signature_template": "<string>",
// "ticket_form_ids": "<array>",
// "updated_at": "<dateTime>",
// "url": "<string>"
// }
// }
CkJsonObjectW json;
json.UpdateString(L"brand.name",L"<string>");
json.UpdateString(L"brand.subdomain",L"<string>");
json.UpdateString(L"brand.active",L"<boolean>");
json.UpdateString(L"brand.brand_url",L"<string>");
json.UpdateString(L"brand.created_at",L"<dateTime>");
json.UpdateString(L"brand.default",L"<boolean>");
json.UpdateString(L"brand.has_help_center",L"<boolean>");
json.UpdateString(L"brand.help_center_state",L"enabled");
json.UpdateString(L"brand.host_mapping",L"<string>");
json.UpdateString(L"brand.id",L"<integer>");
json.UpdateString(L"brand.is_deleted",L"<boolean>");
json.UpdateString(L"brand.logo.content_type",L"<string>");
json.UpdateString(L"brand.logo.content_url",L"<string>");
json.UpdateString(L"brand.logo.deleted",L"<boolean>");
json.UpdateString(L"brand.logo.file_name",L"<string>");
json.UpdateString(L"brand.logo.height",L"<string>");
json.UpdateString(L"brand.logo.id",L"<integer>");
json.UpdateString(L"brand.logo.inline",L"<boolean>");
json.UpdateString(L"brand.logo.malware_access_override",L"<boolean>");
json.UpdateString(L"brand.logo.malware_scan_result",L"<string>");
json.UpdateString(L"brand.logo.mapped_content_url",L"<string>");
json.UpdateString(L"brand.logo.size",L"<integer>");
json.UpdateString(L"brand.logo.url",L"<string>");
json.UpdateString(L"brand.logo.width",L"<string>");
json.UpdateString(L"brand.logo.thumbnails[0].content_type",L"<string>");
json.UpdateString(L"brand.logo.thumbnails[0].content_url",L"<string>");
json.UpdateString(L"brand.logo.thumbnails[0].deleted",L"<boolean>");
json.UpdateString(L"brand.logo.thumbnails[0].file_name",L"<string>");
json.UpdateString(L"brand.logo.thumbnails[0].height",L"<string>");
json.UpdateString(L"brand.logo.thumbnails[0].id",L"<integer>");
json.UpdateString(L"brand.logo.thumbnails[0].inline",L"<boolean>");
json.UpdateString(L"brand.logo.thumbnails[0].malware_access_override",L"<boolean>");
json.UpdateString(L"brand.logo.thumbnails[0].malware_scan_result",L"<string>");
json.UpdateString(L"brand.logo.thumbnails[0].mapped_content_url",L"<string>");
json.UpdateString(L"brand.logo.thumbnails[0].size",L"<integer>");
json.UpdateString(L"brand.logo.thumbnails[0].url",L"<string>");
json.UpdateString(L"brand.logo.thumbnails[0].width",L"<string>");
json.UpdateString(L"brand.logo.thumbnails[1].content_type",L"<string>");
json.UpdateString(L"brand.logo.thumbnails[1].content_url",L"<string>");
json.UpdateString(L"brand.logo.thumbnails[1].deleted",L"<boolean>");
json.UpdateString(L"brand.logo.thumbnails[1].file_name",L"<string>");
json.UpdateString(L"brand.logo.thumbnails[1].height",L"<string>");
json.UpdateString(L"brand.logo.thumbnails[1].id",L"<integer>");
json.UpdateString(L"brand.logo.thumbnails[1].inline",L"<boolean>");
json.UpdateString(L"brand.logo.thumbnails[1].malware_access_override",L"<boolean>");
json.UpdateString(L"brand.logo.thumbnails[1].malware_scan_result",L"<string>");
json.UpdateString(L"brand.logo.thumbnails[1].mapped_content_url",L"<string>");
json.UpdateString(L"brand.logo.thumbnails[1].size",L"<integer>");
json.UpdateString(L"brand.logo.thumbnails[1].url",L"<string>");
json.UpdateString(L"brand.logo.thumbnails[1].width",L"<string>");
json.UpdateString(L"brand.signature_template",L"<string>");
json.UpdateString(L"brand.ticket_form_ids",L"<array>");
json.UpdateString(L"brand.updated_at",L"<dateTime>");
json.UpdateString(L"brand.url",L"<string>");
http.SetRequestHeader(L"Content-Type",L"application/json");
http.SetRequestHeader(L"Accept",L"application/json");
CkHttpResponseW *resp = http.PostJson3(L"https://example.zendesk.com/api/v2/brands",L"application/json",json);
if (http.get_LastMethodSuccess() == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
CkStringBuilderW sbResponseBody;
resp->GetBodySb(sbResponseBody);
CkJsonObjectW jResp;
jResp.LoadSb(sbResponseBody);
jResp.put_EmitCompact(false);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",jResp.emit());
int respStatusCode = resp->get_StatusCode();
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",resp->header());
wprintf(L"Failed.\n");
delete resp;
return;
}
delete resp;
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "brand": {
// "name": "<string>",
// "subdomain": "<string>",
// "active": "<boolean>",
// "brand_url": "<string>",
// "created_at": "<dateTime>",
// "default": "<boolean>",
// "has_help_center": "<boolean>",
// "help_center_state": "enabled",
// "host_mapping": "<string>",
// "id": "<integer>",
// "is_deleted": "<boolean>",
// "logo": {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>",
// "thumbnails": [
// {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>"
// },
// {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>"
// }
// ]
// },
// "signature_template": "<string>",
// "ticket_form_ids": "<array>",
// "updated_at": "<dateTime>",
// "url": "<string>"
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
const wchar_t *content_type = 0;
const wchar_t *content_url = 0;
const wchar_t *deleted = 0;
const wchar_t *file_name = 0;
const wchar_t *height = 0;
const wchar_t *id = 0;
const wchar_t *inline = 0;
const wchar_t *malware_access_override = 0;
const wchar_t *malware_scan_result = 0;
const wchar_t *mapped_content_url = 0;
const wchar_t *size = 0;
const wchar_t *url = 0;
const wchar_t *width = 0;
const wchar_t *Name = jResp.stringOf(L"brand.name");
const wchar_t *Subdomain = jResp.stringOf(L"brand.subdomain");
const wchar_t *Active = jResp.stringOf(L"brand.active");
const wchar_t *Brand_url = jResp.stringOf(L"brand.brand_url");
const wchar_t *Created_at = jResp.stringOf(L"brand.created_at");
const wchar_t *Default = jResp.stringOf(L"brand.default");
const wchar_t *Has_help_center = jResp.stringOf(L"brand.has_help_center");
const wchar_t *Help_center_state = jResp.stringOf(L"brand.help_center_state");
const wchar_t *Host_mapping = jResp.stringOf(L"brand.host_mapping");
const wchar_t *Id = jResp.stringOf(L"brand.id");
const wchar_t *Is_deleted = jResp.stringOf(L"brand.is_deleted");
const wchar_t *Content_type = jResp.stringOf(L"brand.logo.content_type");
const wchar_t *Content_url = jResp.stringOf(L"brand.logo.content_url");
const wchar_t *Deleted = jResp.stringOf(L"brand.logo.deleted");
const wchar_t *File_name = jResp.stringOf(L"brand.logo.file_name");
const wchar_t *Height = jResp.stringOf(L"brand.logo.height");
const wchar_t *LogoId = jResp.stringOf(L"brand.logo.id");
const wchar_t *Inline = jResp.stringOf(L"brand.logo.inline");
const wchar_t *Malware_access_override = jResp.stringOf(L"brand.logo.malware_access_override");
const wchar_t *Malware_scan_result = jResp.stringOf(L"brand.logo.malware_scan_result");
const wchar_t *Mapped_content_url = jResp.stringOf(L"brand.logo.mapped_content_url");
const wchar_t *Size = jResp.stringOf(L"brand.logo.size");
const wchar_t *v_Url = jResp.stringOf(L"brand.logo.url");
const wchar_t *Width = jResp.stringOf(L"brand.logo.width");
const wchar_t *Signature_template = jResp.stringOf(L"brand.signature_template");
const wchar_t *Ticket_form_ids = jResp.stringOf(L"brand.ticket_form_ids");
const wchar_t *Updated_at = jResp.stringOf(L"brand.updated_at");
const wchar_t *brandUrl = jResp.stringOf(L"brand.url");
int i = 0;
int count_i = jResp.SizeOfArray(L"brand.logo.thumbnails");
while (i < count_i) {
jResp.put_I(i);
content_type = jResp.stringOf(L"brand.logo.thumbnails[i].content_type");
content_url = jResp.stringOf(L"brand.logo.thumbnails[i].content_url");
deleted = jResp.stringOf(L"brand.logo.thumbnails[i].deleted");
file_name = jResp.stringOf(L"brand.logo.thumbnails[i].file_name");
height = jResp.stringOf(L"brand.logo.thumbnails[i].height");
id = jResp.stringOf(L"brand.logo.thumbnails[i].id");
inline = jResp.stringOf(L"brand.logo.thumbnails[i].inline");
malware_access_override = jResp.stringOf(L"brand.logo.thumbnails[i].malware_access_override");
malware_scan_result = jResp.stringOf(L"brand.logo.thumbnails[i].malware_scan_result");
mapped_content_url = jResp.stringOf(L"brand.logo.thumbnails[i].mapped_content_url");
size = jResp.stringOf(L"brand.logo.thumbnails[i].size");
url = jResp.stringOf(L"brand.logo.thumbnails[i].url");
width = jResp.stringOf(L"brand.logo.thumbnails[i].width");
i = i + 1;
}
}
Curl Command
curl -u login:password -X POST
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"brand": {
"name": "<string>",
"subdomain": "<string>",
"active": "<boolean>",
"brand_url": "<string>",
"created_at": "<dateTime>",
"default": "<boolean>",
"has_help_center": "<boolean>",
"help_center_state": "enabled",
"host_mapping": "<string>",
"id": "<integer>",
"is_deleted": "<boolean>",
"logo": {
"content_type": "<string>",
"content_url": "<string>",
"deleted": "<boolean>",
"file_name": "<string>",
"height": "<string>",
"id": "<integer>",
"inline": "<boolean>",
"malware_access_override": "<boolean>",
"malware_scan_result": "<string>",
"mapped_content_url": "<string>",
"size": "<integer>",
"url": "<string>",
"width": "<string>",
"thumbnails": [
{
"content_type": "<string>",
"content_url": "<string>",
"deleted": "<boolean>",
"file_name": "<string>",
"height": "<string>",
"id": "<integer>",
"inline": "<boolean>",
"malware_access_override": "<boolean>",
"malware_scan_result": "<string>",
"mapped_content_url": "<string>",
"size": "<integer>",
"url": "<string>",
"width": "<string>"
},
{
"content_type": "<string>",
"content_url": "<string>",
"deleted": "<boolean>",
"file_name": "<string>",
"height": "<string>",
"id": "<integer>",
"inline": "<boolean>",
"malware_access_override": "<boolean>",
"malware_scan_result": "<string>",
"mapped_content_url": "<string>",
"size": "<integer>",
"url": "<string>",
"width": "<string>"
}
]
},
"signature_template": "<string>",
"ticket_form_ids": "<array>",
"updated_at": "<dateTime>",
"url": "<string>"
}
}'
https://example.zendesk.com/api/v2/brands
Postman Collection Item JSON
{
"name": "Create Brand",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"brand\": {\n \"name\": \"<string>\",\n \"subdomain\": \"<string>\",\n \"active\": \"<boolean>\",\n \"brand_url\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"has_help_center\": \"<boolean>\",\n \"help_center_state\": \"enabled\",\n \"host_mapping\": \"<string>\",\n \"id\": \"<integer>\",\n \"is_deleted\": \"<boolean>\",\n \"logo\": {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\",\n \"thumbnails\": [\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\"\n },\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\"\n }\n ]\n },\n \"signature_template\": \"<string>\",\n \"ticket_form_ids\": \"<array>\",\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/brands",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"brands"
]
},
"description": "#### Allowed for\n- Admins"
},
"response": [
{
"name": "Successful response",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"brand\": {\n \"name\": \"<string>\",\n \"subdomain\": \"<string>\",\n \"active\": \"<boolean>\",\n \"brand_url\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"has_help_center\": \"<boolean>\",\n \"help_center_state\": \"enabled\",\n \"host_mapping\": \"<string>\",\n \"id\": \"<integer>\",\n \"is_deleted\": \"<boolean>\",\n \"logo\": {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\",\n \"thumbnails\": [\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\"\n },\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\"\n }\n ]\n },\n \"signature_template\": \"<string>\",\n \"ticket_form_ids\": \"<array>\",\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/brands",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"brands"
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"brand\": {\n \"name\": \"<string>\",\n \"subdomain\": \"<string>\",\n \"active\": \"<boolean>\",\n \"brand_url\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"has_help_center\": \"<boolean>\",\n \"help_center_state\": \"enabled\",\n \"host_mapping\": \"<string>\",\n \"id\": \"<integer>\",\n \"is_deleted\": \"<boolean>\",\n \"logo\": {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\",\n \"thumbnails\": [\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\"\n },\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\"\n }\n ]\n },\n \"signature_template\": \"<string>\",\n \"ticket_form_ids\": \"<array>\",\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\"\n }\n}"
}
]
}