Delphi DLL 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"

Delphi DLL Example

var
rest: HCkRest;
success: Boolean;
bTls: Boolean;
port: Integer;
bAutoReconnect: Boolean;
sbResponseBody: HCkStringBuilder;
jsonResponse: HCkJsonObject;
total_count: Integer;
i: Integer;
count_i: Integer;
type: PWideChar;
id: PWideChar;
created_byType: PWideChar;
created_byId: PWideChar;
created_byName: PWideChar;
created_byLogin: PWideChar;
created_at: PWideChar;
modified_at: PWideChar;
expires_at: Boolean;
status: PWideChar;
accessible_byType: PWideChar;
accessible_byId: PWideChar;
accessible_byName: PWideChar;
accessible_byLogin: PWideChar;
role: PWideChar;
acknowledged_at: PWideChar;
item: Boolean;

begin
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) then
  begin
    Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(CkRest_getConnectFailReason(rest)));
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;

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) then
  begin
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;

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 do
  begin
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;
  end;

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