Search code examples
box-apibox

Getting User Tasks with Box API 2.0


Using Box's REST API, is there a way to retrieve all tasks assigned to a user (if only for the current/API user)? I've read the docs over and over and I can't seem to find it. Am I just missing it? Thanks!


Solution

  • As you mentioned, the Box API does not have an endpoint that directly provides a list of task assignments for a user. The workaround is using the Enterprise Events endpoint to get this info.

    The Enterprise Events endpoint returns events for an entire Box instance including all of its users.

    You can limit the results by specifying the event type needed. To get a list of task assignments, set TASK_ASSIGNMENT_CREATE as the value of the event_type parameter.

    curl https://api.box.com/2.0/events?stream_type=admin_logs&event_type=TASK_ASSIGNMENT_CREATE \
    -H "Authorization: Bearer ACCESS_TOKEN"
    

    You will then need to call the Enterprise Events to check for any deleted task assignments, and remove deleted tasks assignments from the first list.

    curl https://api.box.com/2.0/events?stream_type=admin_logs&event_type=TASK_ASSIGNMENT_DELETE \
    -H "Authorization: Bearer ACCESS_TOKEN"
    

    After getting the list of tasks assignments for all users, you will need to parse through the results by looking for the specific Box user needed using their Box user id.