Visual FoxPro 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"

Visual FoxPro Example

LOCAL loRest
LOCAL lnSuccess
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL loSbResponseBody
LOCAL loJsonResponse
LOCAL lnTotal_count
LOCAL i
LOCAL lnCount_i
LOCAL lcType
LOCAL lcId
LOCAL lcCreated_byType
LOCAL lcCreated_byId
LOCAL lcCreated_byName
LOCAL lcCreated_byLogin
LOCAL lcCreated_at
LOCAL lcModified_at
LOCAL lnExpires_at
LOCAL lcStatus
LOCAL lcAccessible_byType
LOCAL lcAccessible_byId
LOCAL lcAccessible_byName
LOCAL lcAccessible_byLogin
LOCAL lcRole
LOCAL lcAcknowledged_at
LOCAL lnItem

loRest = CreateObject('Chilkat_9_5_0.Rest')

*  URL: https://api.box.com/2.0/folders/FOLDER_ID/collaborations
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("api.box.com",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
    ? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
    ? loRest.LastErrorText
    RELEASE loRest
    CANCEL
ENDIF

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

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/2.0/folders/FOLDER_ID/collaborations",loSbResponseBody)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loSbResponseBody
    CANCEL
ENDIF

loJsonResponse = CreateObject('Chilkat_9_5_0.JsonObject')
loJsonResponse.LoadSb(loSbResponseBody)

lnTotal_count = loJsonResponse.IntOf("total_count")
i = 0
lnCount_i = loJsonResponse.SizeOfArray("entries")
DO WHILE i < lnCount_i
    loJsonResponse.I = i
    lcType = loJsonResponse.StringOf("entries[i].type")
    lcId = loJsonResponse.StringOf("entries[i].id")
    lcCreated_byType = loJsonResponse.StringOf("entries[i].created_by.type")
    lcCreated_byId = loJsonResponse.StringOf("entries[i].created_by.id")
    lcCreated_byName = loJsonResponse.StringOf("entries[i].created_by.name")
    lcCreated_byLogin = loJsonResponse.StringOf("entries[i].created_by.login")
    lcCreated_at = loJsonResponse.StringOf("entries[i].created_at")
    lcModified_at = loJsonResponse.StringOf("entries[i].modified_at")
    lnExpires_at = loJsonResponse.IsNullOf("entries[i].expires_at")
    lcStatus = loJsonResponse.StringOf("entries[i].status")
    lcAccessible_byType = loJsonResponse.StringOf("entries[i].accessible_by.type")
    lcAccessible_byId = loJsonResponse.StringOf("entries[i].accessible_by.id")
    lcAccessible_byName = loJsonResponse.StringOf("entries[i].accessible_by.name")
    lcAccessible_byLogin = loJsonResponse.StringOf("entries[i].accessible_by.login")
    lcRole = loJsonResponse.StringOf("entries[i].role")
    lcAcknowledged_at = loJsonResponse.StringOf("entries[i].acknowledged_at")
    lnItem = loJsonResponse.IsNullOf("entries[i].item")
    i = i + 1
ENDDO

RELEASE loRest
RELEASE loSbResponseBody
RELEASE loJsonResponse

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