Gets the folder info for the root folder of a Box.com account. The root folder of a box.com account always has an id = "0".
curl https://api.box.com/2.0/folders/0 \
-H "Authorization: Bearer BOX_ACCESS_TOKEN" \
#include <C_CkRest.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>
void ChilkatSample(void)
{
HCkRest rest;
BOOL success;
BOOL bTls;
int port;
BOOL bAutoReconnect;
HCkStringBuilder sbResponseBody;
HCkJsonObject jsonResponse;
const char *type;
const char *id;
BOOL sequence_id;
BOOL etag;
const char *name;
BOOL created_at;
BOOL modified_at;
const char *description;
int size;
int path_collectionTotal_count;
const char *created_byType;
const char *created_byId;
const char *created_byName;
const char *created_byLogin;
const char *modified_byType;
const char *modified_byId;
const char *modified_byName;
const char *modified_byLogin;
BOOL trashed_at;
BOOL purged_at;
BOOL content_created_at;
BOOL content_modified_at;
const char *owned_byType;
const char *owned_byId;
const char *owned_byName;
const char *owned_byLogin;
BOOL shared_link;
BOOL folder_upload_email;
BOOL parent;
const char *item_status;
int item_collectionTotal_count;
int item_collectionOffset;
int item_collectionLimit;
int i;
int count_i;
const char *file_versionType;
const char *file_versionId;
const char *file_versionSha1;
const char *sequence_id_str;
const char *etag_str;
const char *sha1;
const char *by;
const char *direction;
rest = CkRest_Create();
// URL: https://api.box.com/2.0/folders/0
bTls = TRUE;
port = 443;
bAutoReconnect = TRUE;
success = CkRest_Connect(rest,"api.box.com",port,bTls,bAutoReconnect);
if (success != TRUE) {
printf("ConnectFailReason: %d\n",CkRest_getConnectFailReason(rest));
printf("%s\n",CkRest_lastErrorText(rest));
CkRest_Dispose(rest);
return;
}
CkRest_AddHeader(rest,"Authorization","Bearer BOX_ACCESS_TOKEN");
sbResponseBody = CkStringBuilder_Create();
success = CkRest_FullRequestNoBodySb(rest,"GET","/2.0/folders/0",sbResponseBody);
if (success != TRUE) {
printf("%s\n",CkRest_lastErrorText(rest));
CkRest_Dispose(rest);
CkStringBuilder_Dispose(sbResponseBody);
return;
}
jsonResponse = CkJsonObject_Create();
CkJsonObject_LoadSb(jsonResponse,sbResponseBody);
type = CkJsonObject_stringOf(jsonResponse,"type");
id = CkJsonObject_stringOf(jsonResponse,"id");
sequence_id = CkJsonObject_IsNullOf(jsonResponse,"sequence_id");
etag = CkJsonObject_IsNullOf(jsonResponse,"etag");
name = CkJsonObject_stringOf(jsonResponse,"name");
created_at = CkJsonObject_IsNullOf(jsonResponse,"created_at");
modified_at = CkJsonObject_IsNullOf(jsonResponse,"modified_at");
description = CkJsonObject_stringOf(jsonResponse,"description");
size = CkJsonObject_IntOf(jsonResponse,"size");
path_collectionTotal_count = CkJsonObject_IntOf(jsonResponse,"path_collection.total_count");
created_byType = CkJsonObject_stringOf(jsonResponse,"created_by.type");
created_byId = CkJsonObject_stringOf(jsonResponse,"created_by.id");
created_byName = CkJsonObject_stringOf(jsonResponse,"created_by.name");
created_byLogin = CkJsonObject_stringOf(jsonResponse,"created_by.login");
modified_byType = CkJsonObject_stringOf(jsonResponse,"modified_by.type");
modified_byId = CkJsonObject_stringOf(jsonResponse,"modified_by.id");
modified_byName = CkJsonObject_stringOf(jsonResponse,"modified_by.name");
modified_byLogin = CkJsonObject_stringOf(jsonResponse,"modified_by.login");
trashed_at = CkJsonObject_IsNullOf(jsonResponse,"trashed_at");
purged_at = CkJsonObject_IsNullOf(jsonResponse,"purged_at");
content_created_at = CkJsonObject_IsNullOf(jsonResponse,"content_created_at");
content_modified_at = CkJsonObject_IsNullOf(jsonResponse,"content_modified_at");
owned_byType = CkJsonObject_stringOf(jsonResponse,"owned_by.type");
owned_byId = CkJsonObject_stringOf(jsonResponse,"owned_by.id");
owned_byName = CkJsonObject_stringOf(jsonResponse,"owned_by.name");
owned_byLogin = CkJsonObject_stringOf(jsonResponse,"owned_by.login");
shared_link = CkJsonObject_IsNullOf(jsonResponse,"shared_link");
folder_upload_email = CkJsonObject_IsNullOf(jsonResponse,"folder_upload_email");
parent = CkJsonObject_IsNullOf(jsonResponse,"parent");
item_status = CkJsonObject_stringOf(jsonResponse,"item_status");
item_collectionTotal_count = CkJsonObject_IntOf(jsonResponse,"item_collection.total_count");
item_collectionOffset = CkJsonObject_IntOf(jsonResponse,"item_collection.offset");
item_collectionLimit = CkJsonObject_IntOf(jsonResponse,"item_collection.limit");
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"path_collection.entries");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"item_collection.entries");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
type = CkJsonObject_stringOf(jsonResponse,"item_collection.entries[i].type");
id = CkJsonObject_stringOf(jsonResponse,"item_collection.entries[i].id");
file_versionType = CkJsonObject_stringOf(jsonResponse,"item_collection.entries[i].file_version.type");
file_versionId = CkJsonObject_stringOf(jsonResponse,"item_collection.entries[i].file_version.id");
file_versionSha1 = CkJsonObject_stringOf(jsonResponse,"item_collection.entries[i].file_version.sha1");
sequence_id_str = CkJsonObject_stringOf(jsonResponse,"item_collection.entries[i].sequence_id");
etag_str = CkJsonObject_stringOf(jsonResponse,"item_collection.entries[i].etag");
sha1 = CkJsonObject_stringOf(jsonResponse,"item_collection.entries[i].sha1");
name = CkJsonObject_stringOf(jsonResponse,"item_collection.entries[i].name");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"item_collection.order");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
by = CkJsonObject_stringOf(jsonResponse,"item_collection.order[i].by");
direction = CkJsonObject_stringOf(jsonResponse,"item_collection.order[i].direction");
i = i + 1;
}
CkRest_Dispose(rest);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jsonResponse);
}
{
"type": "folder",
"id": "0",
"sequence_id": null,
"etag": null,
"name": "All Files",
"created_at": null,
"modified_at": null,
"description": "",
"size": 826408,
"path_collection": {
"total_count": 0,
"entries": [
]
},
"created_by": {
"type": "user",
"id": "",
"name": "",
"login": ""
},
"modified_by": {
"type": "user",
"id": "2787704945",
"name": "chilkat",
"login": "AutomationUser_434741_3nmGYSS7o5@@boxdevedition.com"
},
"trashed_at": null,
"purged_at": null,
"content_created_at": null,
"content_modified_at": null,
"owned_by": {
"type": "user",
"id": "2787704945",
"name": "chilkat",
"login": "AutomationUser_434741_3nmGYSS7o5@@boxdevedition.com"
},
"shared_link": null,
"folder_upload_email": null,
"parent": null,
"item_status": "active",
"item_collection": {
"total_count": 2,
"entries": [
{
"type": "file",
"id": "246181882790",
"file_version": {
"type": "file_version",
"id": "259636211878",
"sha1": "c9d2492fb97f88a9b4d1e35f32a3410e95853f18"
},
"sequence_id": "0",
"etag": "0",
"sha1": "c9d2492fb97f88a9b4d1e35f32a3410e95853f18",
"name": "hedgehogs.jpg"
},
{
"type": "file",
"id": "246167973161",
"file_version": {
"type": "file_version",
"id": "259621592361",
"sha1": "df7be9dc4f467187783aca68c7ce98e4df2172d0"
},
"sequence_id": "0",
"etag": "0",
"sha1": "df7be9dc4f467187783aca68c7ce98e4df2172d0",
"name": "penguins.jpg"
}
],
"offset": 0,
"limit": 100,
"order": [
{
"by": "type",
"direction": "ASC"
},
{
"by": "name",
"direction": "ASC"
}
]
}
}