Gets all of the files, folders, or web links contained within a folder.
curl https://api.box.com/2.0/folders/BOX_FOLDER_ID/items?limit=2&offset=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;
int total_count;
int offset;
int limit;
int i;
int count_i;
const char *type;
const char *id;
const char *file_versionType;
const char *file_versionId;
const char *file_versionSha1;
const char *sequence_id;
const char *etag;
const char *sha1;
const char *name;
const char *by;
const char *direction;
rest = CkRest_Create();
// URL: https://api.box.com/2.0/folders/BOX_FOLDER_ID/items?limit=2&offset=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/BOX_FOLDER_ID/items?limit=2&offset=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);
total_count = CkJsonObject_IntOf(jsonResponse,"total_count");
offset = CkJsonObject_IntOf(jsonResponse,"offset");
limit = CkJsonObject_IntOf(jsonResponse,"limit");
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"entries");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
type = CkJsonObject_stringOf(jsonResponse,"entries[i].type");
id = CkJsonObject_stringOf(jsonResponse,"entries[i].id");
file_versionType = CkJsonObject_stringOf(jsonResponse,"entries[i].file_version.type");
file_versionId = CkJsonObject_stringOf(jsonResponse,"entries[i].file_version.id");
file_versionSha1 = CkJsonObject_stringOf(jsonResponse,"entries[i].file_version.sha1");
sequence_id = CkJsonObject_stringOf(jsonResponse,"entries[i].sequence_id");
etag = CkJsonObject_stringOf(jsonResponse,"entries[i].etag");
sha1 = CkJsonObject_stringOf(jsonResponse,"entries[i].sha1");
name = CkJsonObject_stringOf(jsonResponse,"entries[i].name");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"order");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
by = CkJsonObject_stringOf(jsonResponse,"order[i].by");
direction = CkJsonObject_stringOf(jsonResponse,"order[i].direction");
i = i + 1;
}
CkRest_Dispose(rest);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jsonResponse);
}
{
"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": 2,
"order": [
{
"by": "type",
"direction": "ASC"
},
{
"by": "name",
"direction": "ASC"
}
]
}