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

PowerBuilder Example

integer li_rc
oleobject loo_Rest
integer li_Success
integer li_BTls
integer li_Port
integer li_BAutoReconnect
oleobject loo_SbResponseBody
oleobject loo_JsonResponse
integer li_Total_count
integer i
integer li_Count_i
string ls_Type
string ls_Id
string ls_Created_byType
string ls_Created_byId
string ls_Created_byName
string ls_Created_byLogin
string ls_Created_at
string ls_Modified_at
integer li_Expires_at
string ls_Status
string ls_Accessible_byType
string ls_Accessible_byId
string ls_Accessible_byName
string ls_Accessible_byLogin
string ls_Role
string ls_Acknowledged_at
integer li_Item

loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat_9_5_0.Rest")
if li_rc < 0 then
    destroy loo_Rest
    MessageBox("Error","Connecting to COM object failed")
    return
end if

//  URL: https://api.box.com/2.0/folders/FOLDER_ID/collaborations
li_BTls = 1
li_Port = 443
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("api.box.com",li_Port,li_BTls,li_BAutoReconnect)
if li_Success <> 1 then
    Write-Debug "ConnectFailReason: " + string(loo_Rest.ConnectFailReason)
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    return
end if

loo_Rest.AddHeader("Authorization","Bearer BOX_ACCESS_TOKEN")

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Rest.FullRequestNoBodySb("GET","/2.0/folders/FOLDER_ID/collaborations",loo_SbResponseBody)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_SbResponseBody
    return
end if

loo_JsonResponse = create oleobject
li_rc = loo_JsonResponse.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JsonResponse.LoadSb(loo_SbResponseBody)

li_Total_count = loo_JsonResponse.IntOf("total_count")
i = 0
li_Count_i = loo_JsonResponse.SizeOfArray("entries")
do while i < li_Count_i
    loo_JsonResponse.I = i
    ls_Type = loo_JsonResponse.StringOf("entries[i].type")
    ls_Id = loo_JsonResponse.StringOf("entries[i].id")
    ls_Created_byType = loo_JsonResponse.StringOf("entries[i].created_by.type")
    ls_Created_byId = loo_JsonResponse.StringOf("entries[i].created_by.id")
    ls_Created_byName = loo_JsonResponse.StringOf("entries[i].created_by.name")
    ls_Created_byLogin = loo_JsonResponse.StringOf("entries[i].created_by.login")
    ls_Created_at = loo_JsonResponse.StringOf("entries[i].created_at")
    ls_Modified_at = loo_JsonResponse.StringOf("entries[i].modified_at")
    li_Expires_at = loo_JsonResponse.IsNullOf("entries[i].expires_at")
    ls_Status = loo_JsonResponse.StringOf("entries[i].status")
    ls_Accessible_byType = loo_JsonResponse.StringOf("entries[i].accessible_by.type")
    ls_Accessible_byId = loo_JsonResponse.StringOf("entries[i].accessible_by.id")
    ls_Accessible_byName = loo_JsonResponse.StringOf("entries[i].accessible_by.name")
    ls_Accessible_byLogin = loo_JsonResponse.StringOf("entries[i].accessible_by.login")
    ls_Role = loo_JsonResponse.StringOf("entries[i].role")
    ls_Acknowledged_at = loo_JsonResponse.StringOf("entries[i].acknowledged_at")
    li_Item = loo_JsonResponse.IsNullOf("entries[i].item")
    i = i + 1
loop


destroy loo_Rest
destroy loo_SbResponseBody
destroy loo_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
    }
  ]
}