Unicode C++ Box: Get Folder Collaborations

Back to Index

Returns all of the folder's collaborations. This API does not support paging -- it always returns all of the collaborations. Each collaboration object has details on which user or group has access to the file and with what role.

Documentation: https://developer.box.com/reference#view-a-folders-collaborations

CURL Command

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

Unicode C++ Example

#include <CkRestW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>

void ChilkatSample(void)
    {
    CkRestW rest;
    bool success;

    //  URL: https://api.box.com/2.0/folders/FOLDER_ID/collaborations
    bool bTls = true;
    int port = 443;
    bool bAutoReconnect = true;
    success = rest.Connect(L"api.box.com",port,bTls,bAutoReconnect);
    if (success != true) {
        wprintf(L"ConnectFailReason: %d\n",rest.get_ConnectFailReason());
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    rest.AddHeader(L"Authorization",L"Bearer BOX_ACCESS_TOKEN");

    CkStringBuilderW sbResponseBody;
    success = rest.FullRequestNoBodySb(L"GET",L"/2.0/folders/FOLDER_ID/collaborations",sbResponseBody);
    if (success != true) {
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    CkJsonObjectW jsonResponse;
    jsonResponse.LoadSb(sbResponseBody);

    int total_count;
    int i;
    int count_i;
    const wchar_t *type = 0;
    const wchar_t *id = 0;
    const wchar_t *created_byType = 0;
    const wchar_t *created_byId = 0;
    const wchar_t *created_byName = 0;
    const wchar_t *created_byLogin = 0;
    const wchar_t *created_at = 0;
    const wchar_t *modified_at = 0;
    bool expires_at;
    const wchar_t *status = 0;
    const wchar_t *accessible_byType = 0;
    const wchar_t *accessible_byId = 0;
    const wchar_t *accessible_byName = 0;
    const wchar_t *accessible_byLogin = 0;
    const wchar_t *role = 0;
    const wchar_t *acknowledged_at = 0;
    bool item;

    total_count = jsonResponse.IntOf(L"total_count");
    i = 0;
    count_i = jsonResponse.SizeOfArray(L"entries");
    while (i < count_i) {
        jsonResponse.put_I(i);
        type = jsonResponse.stringOf(L"entries[i].type");
        id = jsonResponse.stringOf(L"entries[i].id");
        created_byType = jsonResponse.stringOf(L"entries[i].created_by.type");
        created_byId = jsonResponse.stringOf(L"entries[i].created_by.id");
        created_byName = jsonResponse.stringOf(L"entries[i].created_by.name");
        created_byLogin = jsonResponse.stringOf(L"entries[i].created_by.login");
        created_at = jsonResponse.stringOf(L"entries[i].created_at");
        modified_at = jsonResponse.stringOf(L"entries[i].modified_at");
        expires_at = jsonResponse.IsNullOf(L"entries[i].expires_at");
        status = jsonResponse.stringOf(L"entries[i].status");
        accessible_byType = jsonResponse.stringOf(L"entries[i].accessible_by.type");
        accessible_byId = jsonResponse.stringOf(L"entries[i].accessible_by.id");
        accessible_byName = jsonResponse.stringOf(L"entries[i].accessible_by.name");
        accessible_byLogin = jsonResponse.stringOf(L"entries[i].accessible_by.login");
        role = jsonResponse.stringOf(L"entries[i].role");
        acknowledged_at = jsonResponse.stringOf(L"entries[i].acknowledged_at");
        item = jsonResponse.IsNullOf(L"entries[i].item");
        i = i + 1;
    }
    }

Sample JSON Response Body

{
  "total_count": 1,
  "entries": [
    {
      "type": "collaboration",
      "id": "14176246",
      "created_by": {
        "type": "user",
        "id": "4276790",
        "name": "David Lee",
        "login": "david@box.com"
      },
      "created_at": "2011-11-29T12:56:35-08:00",
      "modified_at": "2012-09-11T15:12:32-07:00",
      "expires_at": null,
      "status": "accepted",
      "accessible_by": {
        "type": "user",
        "id": "755492",
        "name": "Simon Tan",
        "login": "simon@box.net"
      },
      "role": "editor",
      "acknowledged_at": "2011-11-29T12:59:40-08:00",
      "item": null
    }
  ]
}