Android™ 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"

Android™ Example

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    CkRest rest = new CkRest();
    boolean success;

    //  URL: https://api.box.com/2.0/folders/FOLDER_ID/collaborations
    boolean bTls = true;
    int port = 443;
    boolean bAutoReconnect = true;
    success = rest.Connect("api.box.com",port,bTls,bAutoReconnect);
    if (success != true) {
        Log.i(TAG, "ConnectFailReason: " + String.valueOf(rest.get_ConnectFailReason()));
        Log.i(TAG, rest.lastErrorText());
        return;
        }

    rest.AddHeader("Authorization","Bearer BOX_ACCESS_TOKEN");

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    success = rest.FullRequestNoBodySb("GET","/2.0/folders/FOLDER_ID/collaborations",sbResponseBody);
    if (success != true) {
        Log.i(TAG, rest.lastErrorText());
        return;
        }

    CkJsonObject jsonResponse = new CkJsonObject();
    jsonResponse.LoadSb(sbResponseBody);

    int total_count;
    int i;
    int count_i;
    String type;
    String id;
    String created_byType;
    String created_byId;
    String created_byName;
    String created_byLogin;
    String created_at;
    String modified_at;
    boolean expires_at;
    String status;
    String accessible_byType;
    String accessible_byId;
    String accessible_byName;
    String accessible_byLogin;
    String role;
    String acknowledged_at;
    boolean item;

    total_count = jsonResponse.IntOf("total_count");
    i = 0;
    count_i = jsonResponse.SizeOfArray("entries");
    while (i < count_i) {
        jsonResponse.put_I(i);
        type = jsonResponse.stringOf("entries[i].type");
        id = jsonResponse.stringOf("entries[i].id");
        created_byType = jsonResponse.stringOf("entries[i].created_by.type");
        created_byId = jsonResponse.stringOf("entries[i].created_by.id");
        created_byName = jsonResponse.stringOf("entries[i].created_by.name");
        created_byLogin = jsonResponse.stringOf("entries[i].created_by.login");
        created_at = jsonResponse.stringOf("entries[i].created_at");
        modified_at = jsonResponse.stringOf("entries[i].modified_at");
        expires_at = jsonResponse.IsNullOf("entries[i].expires_at");
        status = jsonResponse.stringOf("entries[i].status");
        accessible_byType = jsonResponse.stringOf("entries[i].accessible_by.type");
        accessible_byId = jsonResponse.stringOf("entries[i].accessible_by.id");
        accessible_byName = jsonResponse.stringOf("entries[i].accessible_by.name");
        accessible_byLogin = jsonResponse.stringOf("entries[i].accessible_by.login");
        role = jsonResponse.stringOf("entries[i].role");
        acknowledged_at = jsonResponse.stringOf("entries[i].acknowledged_at");
        item = jsonResponse.IsNullOf("entries[i].item");
        i = i + 1;
        }


  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}

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