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"

C Example

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

    rest = CkRest_Create();

    //  URL: https://api.box.com/2.0/folders/FOLDER_ID/collaborations
    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/FOLDER_ID/collaborations",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");
    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");
        created_byType = CkJsonObject_stringOf(jsonResponse,"entries[i].created_by.type");
        created_byId = CkJsonObject_stringOf(jsonResponse,"entries[i].created_by.id");
        created_byName = CkJsonObject_stringOf(jsonResponse,"entries[i].created_by.name");
        created_byLogin = CkJsonObject_stringOf(jsonResponse,"entries[i].created_by.login");
        created_at = CkJsonObject_stringOf(jsonResponse,"entries[i].created_at");
        modified_at = CkJsonObject_stringOf(jsonResponse,"entries[i].modified_at");
        expires_at = CkJsonObject_IsNullOf(jsonResponse,"entries[i].expires_at");
        status = CkJsonObject_stringOf(jsonResponse,"entries[i].status");
        accessible_byType = CkJsonObject_stringOf(jsonResponse,"entries[i].accessible_by.type");
        accessible_byId = CkJsonObject_stringOf(jsonResponse,"entries[i].accessible_by.id");
        accessible_byName = CkJsonObject_stringOf(jsonResponse,"entries[i].accessible_by.name");
        accessible_byLogin = CkJsonObject_stringOf(jsonResponse,"entries[i].accessible_by.login");
        role = CkJsonObject_stringOf(jsonResponse,"entries[i].role");
        acknowledged_at = CkJsonObject_stringOf(jsonResponse,"entries[i].acknowledged_at");
        item = CkJsonObject_IsNullOf(jsonResponse,"entries[i].item");
        i = i + 1;
    }



    CkRest_Dispose(rest);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_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
    }
  ]
}