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

Tcl Example


load ./chilkat.dll

set rest [new_CkRest]

#  URL: https://api.box.com/2.0/folders/FOLDER_ID/collaborations
set bTls 1
set port 443
set bAutoReconnect 1
set success [CkRest_Connect $rest "api.box.com" $port $bTls $bAutoReconnect]
if {[expr $success != 1]} then {
    puts "ConnectFailReason: [CkRest_ConnectFailReason $rest]"
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    exit
}

CkRest_AddHeader $rest "Authorization" "Bearer BOX_ACCESS_TOKEN"

set sbResponseBody [new_CkStringBuilder]

set success [CkRest_FullRequestNoBodySb $rest "GET" "/2.0/folders/FOLDER_ID/collaborations" $sbResponseBody]
if {[expr $success != 1]} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkStringBuilder $sbResponseBody
    exit
}

set jsonResponse [new_CkJsonObject]

CkJsonObject_LoadSb $jsonResponse $sbResponseBody

set total_count [CkJsonObject_IntOf $jsonResponse "total_count"]
set i 0
set count_i [CkJsonObject_SizeOfArray $jsonResponse "entries"]
while {[expr $i < $count_i]} {
    CkJsonObject_put_I $jsonResponse $i
    set type [CkJsonObject_stringOf $jsonResponse "entries[i].type"]
    set id [CkJsonObject_stringOf $jsonResponse "entries[i].id"]
    set created_byType [CkJsonObject_stringOf $jsonResponse "entries[i].created_by.type"]
    set created_byId [CkJsonObject_stringOf $jsonResponse "entries[i].created_by.id"]
    set created_byName [CkJsonObject_stringOf $jsonResponse "entries[i].created_by.name"]
    set created_byLogin [CkJsonObject_stringOf $jsonResponse "entries[i].created_by.login"]
    set created_at [CkJsonObject_stringOf $jsonResponse "entries[i].created_at"]
    set modified_at [CkJsonObject_stringOf $jsonResponse "entries[i].modified_at"]
    set expires_at [CkJsonObject_IsNullOf $jsonResponse "entries[i].expires_at"]
    set status [CkJsonObject_stringOf $jsonResponse "entries[i].status"]
    set accessible_byType [CkJsonObject_stringOf $jsonResponse "entries[i].accessible_by.type"]
    set accessible_byId [CkJsonObject_stringOf $jsonResponse "entries[i].accessible_by.id"]
    set accessible_byName [CkJsonObject_stringOf $jsonResponse "entries[i].accessible_by.name"]
    set accessible_byLogin [CkJsonObject_stringOf $jsonResponse "entries[i].accessible_by.login"]
    set role [CkJsonObject_stringOf $jsonResponse "entries[i].role"]
    set acknowledged_at [CkJsonObject_stringOf $jsonResponse "entries[i].acknowledged_at"]
    set item [CkJsonObject_IsNullOf $jsonResponse "entries[i].item"]
    set i [expr $i + 1]
}

delete_CkRest $rest
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $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
    }
  ]
}