Renames a folder. This example renames the folder w/ id = 47885473705 to "Old Documents".
curl https://api.box.com/2.0/folders/47885473705 \
-H "Authorization: Bearer BOX_ACCESS_TOKEN" \
-d '{"name":"Old Documents"}' \
-X PUT
#include <C_CkRestW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
HCkRestW rest;
BOOL success;
BOOL bTls;
int port;
BOOL bAutoReconnect;
HCkJsonObjectW json;
HCkStringBuilderW sbRequestBody;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW jsonResponse;
const wchar_t *type;
const wchar_t *id;
const wchar_t *sequence_id;
const wchar_t *etag;
const wchar_t *name;
const wchar_t *created_at;
const wchar_t *modified_at;
const wchar_t *description;
int size;
int path_collectionTotal_count;
const wchar_t *created_byType;
const wchar_t *created_byId;
const wchar_t *created_byName;
const wchar_t *created_byLogin;
const wchar_t *modified_byType;
const wchar_t *modified_byId;
const wchar_t *modified_byName;
const wchar_t *modified_byLogin;
BOOL trashed_at;
BOOL purged_at;
const wchar_t *content_created_at;
const wchar_t *content_modified_at;
const wchar_t *owned_byType;
const wchar_t *owned_byId;
const wchar_t *owned_byName;
const wchar_t *owned_byLogin;
BOOL shared_link;
BOOL folder_upload_email;
const wchar_t *parentType;
const wchar_t *parentId;
BOOL parentSequence_id;
BOOL parentEtag;
const wchar_t *parentName;
const wchar_t *item_status;
int item_collectionTotal_count;
int item_collectionOffset;
int item_collectionLimit;
int i;
int count_i;
BOOL sequence_id_bool;
BOOL etag_bool;
const wchar_t *by;
const wchar_t *direction;
rest = CkRestW_Create();
// URL: https://api.box.com/2.0/folders/47885473705
bTls = TRUE;
port = 443;
bAutoReconnect = TRUE;
success = CkRestW_Connect(rest,L"api.box.com",port,bTls,bAutoReconnect);
if (success != TRUE) {
wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
return;
}
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"name",L"Old Documents");
CkRestW_AddHeader(rest,L"Authorization",L"Bearer BOX_ACCESS_TOKEN");
sbRequestBody = CkStringBuilderW_Create();
CkJsonObjectW_EmitSb(json,sbRequestBody);
sbResponseBody = CkStringBuilderW_Create();
success = CkRestW_FullRequestSb(rest,L"PUT",L"/2.0/folders/47885473705",sbRequestBody,sbResponseBody);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jsonResponse = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jsonResponse,sbResponseBody);
type = CkJsonObjectW_stringOf(jsonResponse,L"type");
id = CkJsonObjectW_stringOf(jsonResponse,L"id");
sequence_id = CkJsonObjectW_stringOf(jsonResponse,L"sequence_id");
etag = CkJsonObjectW_stringOf(jsonResponse,L"etag");
name = CkJsonObjectW_stringOf(jsonResponse,L"name");
created_at = CkJsonObjectW_stringOf(jsonResponse,L"created_at");
modified_at = CkJsonObjectW_stringOf(jsonResponse,L"modified_at");
description = CkJsonObjectW_stringOf(jsonResponse,L"description");
size = CkJsonObjectW_IntOf(jsonResponse,L"size");
path_collectionTotal_count = CkJsonObjectW_IntOf(jsonResponse,L"path_collection.total_count");
created_byType = CkJsonObjectW_stringOf(jsonResponse,L"created_by.type");
created_byId = CkJsonObjectW_stringOf(jsonResponse,L"created_by.id");
created_byName = CkJsonObjectW_stringOf(jsonResponse,L"created_by.name");
created_byLogin = CkJsonObjectW_stringOf(jsonResponse,L"created_by.login");
modified_byType = CkJsonObjectW_stringOf(jsonResponse,L"modified_by.type");
modified_byId = CkJsonObjectW_stringOf(jsonResponse,L"modified_by.id");
modified_byName = CkJsonObjectW_stringOf(jsonResponse,L"modified_by.name");
modified_byLogin = CkJsonObjectW_stringOf(jsonResponse,L"modified_by.login");
trashed_at = CkJsonObjectW_IsNullOf(jsonResponse,L"trashed_at");
purged_at = CkJsonObjectW_IsNullOf(jsonResponse,L"purged_at");
content_created_at = CkJsonObjectW_stringOf(jsonResponse,L"content_created_at");
content_modified_at = CkJsonObjectW_stringOf(jsonResponse,L"content_modified_at");
owned_byType = CkJsonObjectW_stringOf(jsonResponse,L"owned_by.type");
owned_byId = CkJsonObjectW_stringOf(jsonResponse,L"owned_by.id");
owned_byName = CkJsonObjectW_stringOf(jsonResponse,L"owned_by.name");
owned_byLogin = CkJsonObjectW_stringOf(jsonResponse,L"owned_by.login");
shared_link = CkJsonObjectW_IsNullOf(jsonResponse,L"shared_link");
folder_upload_email = CkJsonObjectW_IsNullOf(jsonResponse,L"folder_upload_email");
parentType = CkJsonObjectW_stringOf(jsonResponse,L"parent.type");
parentId = CkJsonObjectW_stringOf(jsonResponse,L"parent.id");
parentSequence_id = CkJsonObjectW_IsNullOf(jsonResponse,L"parent.sequence_id");
parentEtag = CkJsonObjectW_IsNullOf(jsonResponse,L"parent.etag");
parentName = CkJsonObjectW_stringOf(jsonResponse,L"parent.name");
item_status = CkJsonObjectW_stringOf(jsonResponse,L"item_status");
item_collectionTotal_count = CkJsonObjectW_IntOf(jsonResponse,L"item_collection.total_count");
item_collectionOffset = CkJsonObjectW_IntOf(jsonResponse,L"item_collection.offset");
item_collectionLimit = CkJsonObjectW_IntOf(jsonResponse,L"item_collection.limit");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"path_collection.entries");
while (i < count_i) {
CkJsonObjectW_putI(jsonResponse,i);
type = CkJsonObjectW_stringOf(jsonResponse,L"path_collection.entries[i].type");
id = CkJsonObjectW_stringOf(jsonResponse,L"path_collection.entries[i].id");
sequence_id_bool = CkJsonObjectW_IsNullOf(jsonResponse,L"path_collection.entries[i].sequence_id");
etag_bool = CkJsonObjectW_IsNullOf(jsonResponse,L"path_collection.entries[i].etag");
name = CkJsonObjectW_stringOf(jsonResponse,L"path_collection.entries[i].name");
i = i + 1;
}
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"item_collection.entries");
while (i < count_i) {
CkJsonObjectW_putI(jsonResponse,i);
i = i + 1;
}
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"item_collection.order");
while (i < count_i) {
CkJsonObjectW_putI(jsonResponse,i);
by = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.order[i].by");
direction = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.order[i].direction");
i = i + 1;
}
CkRestW_Dispose(rest);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jsonResponse);
}
{
"type": "folder",
"id": "47885473705",
"sequence_id": "1",
"etag": "1",
"name": "Old Documents",
"created_at": "2018-03-16T06:54:57-07:00",
"modified_at": "2018-03-17T08:36:09-07:00",
"description": "",
"size": 0,
"path_collection": {
"total_count": 1,
"entries": [
{
"type": "folder",
"id": "0",
"sequence_id": null,
"etag": null,
"name": "All Files"
}
]
},
"created_by": {
"type": "user",
"id": "2787704945",
"name": "chilkat",
"login": "AutomationUser_434741_3nmGYSS7o5@@boxdevedition.com"
},
"modified_by": {
"type": "user",
"id": "2787704945",
"name": "chilkat",
"login": "AutomationUser_434741_3nmGYSS7o5@@boxdevedition.com"
},
"trashed_at": null,
"purged_at": null,
"content_created_at": "2018-03-16T06:54:57-07:00",
"content_modified_at": "2018-03-17T08:36:09-07:00",
"owned_by": {
"type": "user",
"id": "2787704945",
"name": "chilkat",
"login": "AutomationUser_434741_3nmGYSS7o5@@boxdevedition.com"
},
"shared_link": null,
"folder_upload_email": null,
"parent": {
"type": "folder",
"id": "0",
"sequence_id": null,
"etag": null,
"name": "All Files"
},
"item_status": "active",
"item_collection": {
"total_count": 0,
"entries": [
],
"offset": 0,
"limit": 100,
"order": [
{
"by": "type",
"direction": "ASC"
},
{
"by": "name",
"direction": "ASC"
}
]
}
}