Unicode C Box: Get Root Folder Info

Back to Index

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".

Documentation: https://developer.box.com/reference#get-folder-info

CURL Command

curl https://api.box.com/2.0/folders/0 \
-H "Authorization: Bearer BOX_ACCESS_TOKEN" \

Unicode C Example

#include <C_CkRestW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>

void ChilkatSample(void)
    {
    HCkRestW rest;
    BOOL success;
    BOOL bTls;
    int port;
    BOOL bAutoReconnect;
    HCkStringBuilderW sbResponseBody;
    HCkJsonObjectW jsonResponse;
    const wchar_t *type;
    const wchar_t *id;
    BOOL sequence_id;
    BOOL etag;
    const wchar_t *name;
    BOOL created_at;
    BOOL 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;
    BOOL content_created_at;
    BOOL 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;
    BOOL parent;
    const wchar_t *item_status;
    int item_collectionTotal_count;
    int item_collectionOffset;
    int item_collectionLimit;
    int i;
    int count_i;
    const wchar_t *file_versionType;
    const wchar_t *file_versionId;
    const wchar_t *file_versionSha1;
    const wchar_t *sequence_id_str;
    const wchar_t *etag_str;
    const wchar_t *sha1;
    const wchar_t *by;
    const wchar_t *direction;

    rest = CkRestW_Create();

    //  URL: https://api.box.com/2.0/folders/0
    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;
    }

    CkRestW_AddHeader(rest,L"Authorization",L"Bearer BOX_ACCESS_TOKEN");

    sbResponseBody = CkStringBuilderW_Create();
    success = CkRestW_FullRequestNoBodySb(rest,L"GET",L"/2.0/folders/0",sbResponseBody);
    if (success != TRUE) {
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        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_IsNullOf(jsonResponse,L"sequence_id");
    etag = CkJsonObjectW_IsNullOf(jsonResponse,L"etag");
    name = CkJsonObjectW_stringOf(jsonResponse,L"name");
    created_at = CkJsonObjectW_IsNullOf(jsonResponse,L"created_at");
    modified_at = CkJsonObjectW_IsNullOf(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_IsNullOf(jsonResponse,L"content_created_at");
    content_modified_at = CkJsonObjectW_IsNullOf(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");
    parent = CkJsonObjectW_IsNullOf(jsonResponse,L"parent");
    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);
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"item_collection.entries");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        type = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.entries[i].type");
        id = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.entries[i].id");
        file_versionType = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.entries[i].file_version.type");
        file_versionId = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.entries[i].file_version.id");
        file_versionSha1 = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.entries[i].file_version.sha1");
        sequence_id_str = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.entries[i].sequence_id");
        etag_str = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.entries[i].etag");
        sha1 = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.entries[i].sha1");
        name = CkJsonObjectW_stringOf(jsonResponse,L"item_collection.entries[i].name");
        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);
    CkStringBuilderW_Dispose(sbResponseBody);
    CkJsonObjectW_Dispose(jsonResponse);

    }

Sample JSON Response Body

{
  "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"
      }
    ]
  }
}