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 <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;
    int total_count;
    int i;
    int count_i;
    const wchar_t *type;
    const wchar_t *id;
    const wchar_t *created_byType;
    const wchar_t *created_byId;
    const wchar_t *created_byName;
    const wchar_t *created_byLogin;
    const wchar_t *created_at;
    const wchar_t *modified_at;
    BOOL expires_at;
    const wchar_t *status;
    const wchar_t *accessible_byType;
    const wchar_t *accessible_byId;
    const wchar_t *accessible_byName;
    const wchar_t *accessible_byLogin;
    const wchar_t *role;
    const wchar_t *acknowledged_at;
    BOOL item;

    rest = CkRestW_Create();

    //  URL: https://api.box.com/2.0/folders/FOLDER_ID/collaborations
    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/FOLDER_ID/collaborations",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);

    total_count = CkJsonObjectW_IntOf(jsonResponse,L"total_count");
    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"entries");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        type = CkJsonObjectW_stringOf(jsonResponse,L"entries[i].type");
        id = CkJsonObjectW_stringOf(jsonResponse,L"entries[i].id");
        created_byType = CkJsonObjectW_stringOf(jsonResponse,L"entries[i].created_by.type");
        created_byId = CkJsonObjectW_stringOf(jsonResponse,L"entries[i].created_by.id");
        created_byName = CkJsonObjectW_stringOf(jsonResponse,L"entries[i].created_by.name");
        created_byLogin = CkJsonObjectW_stringOf(jsonResponse,L"entries[i].created_by.login");
        created_at = CkJsonObjectW_stringOf(jsonResponse,L"entries[i].created_at");
        modified_at = CkJsonObjectW_stringOf(jsonResponse,L"entries[i].modified_at");
        expires_at = CkJsonObjectW_IsNullOf(jsonResponse,L"entries[i].expires_at");
        status = CkJsonObjectW_stringOf(jsonResponse,L"entries[i].status");
        accessible_byType = CkJsonObjectW_stringOf(jsonResponse,L"entries[i].accessible_by.type");
        accessible_byId = CkJsonObjectW_stringOf(jsonResponse,L"entries[i].accessible_by.id");
        accessible_byName = CkJsonObjectW_stringOf(jsonResponse,L"entries[i].accessible_by.name");
        accessible_byLogin = CkJsonObjectW_stringOf(jsonResponse,L"entries[i].accessible_by.login");
        role = CkJsonObjectW_stringOf(jsonResponse,L"entries[i].role");
        acknowledged_at = CkJsonObjectW_stringOf(jsonResponse,L"entries[i].acknowledged_at");
        item = CkJsonObjectW_IsNullOf(jsonResponse,L"entries[i].item");
        i = i + 1;
    }



    CkRestW_Dispose(rest);
    CkStringBuilderW_Dispose(sbResponseBody);
    CkJsonObjectW_Dispose(jsonResponse);

    }

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