unicodeCpp / Support API / Update Group
Back to Collection Items
#include <CkHttpW.h>
#include <CkHttpResponseW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.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");
http.SetRequestHeader(L"Accept",L"application/json");
CkHttpResponseW *resp = http.QuickRequest(L"PUT",L"https://example.zendesk.com/api/v2/groups/:group_id");
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)
// {
// "group": {
// "name": "<string>",
// "created_at": "<dateTime>",
// "default": "<boolean>",
// "deleted": "<boolean>",
// "description": "<string>",
// "id": "<integer>",
// "is_public": "<boolean>",
// "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 *Name = jResp.stringOf(L"group.name");
const wchar_t *Created_at = jResp.stringOf(L"group.created_at");
const wchar_t *Default = jResp.stringOf(L"group.default");
const wchar_t *Deleted = jResp.stringOf(L"group.deleted");
const wchar_t *Description = jResp.stringOf(L"group.description");
const wchar_t *Id = jResp.stringOf(L"group.id");
const wchar_t *Is_public = jResp.stringOf(L"group.is_public");
const wchar_t *Updated_at = jResp.stringOf(L"group.updated_at");
const wchar_t *v_Url = jResp.stringOf(L"group.url");
}
Curl Command
curl -u login:password -X PUT
-H "Accept: application/json"
https://example.zendesk.com/api/v2/groups/:group_id
Postman Collection Item JSON
{
"name": "Update Group",
"request": {
"method": "PUT",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/groups/:group_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"groups",
":group_id"
],
"variable": [
{
"key": "group_id",
"value": "<integer>"
}
]
},
"description": "#### Allowed For\n\n* Admins\n"
},
"response": [
{
"name": "Success response",
"originalRequest": {
"method": "PUT",
"header": [
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/groups/:group_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"groups",
":group_id"
],
"variable": [
{
"key": "group_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"group\": {\n \"name\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"deleted\": \"<boolean>\",\n \"description\": \"<string>\",\n \"id\": \"<integer>\",\n \"is_public\": \"<boolean>\",\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\"\n }\n}"
}
]
}