1
votes

How can I get a user or group id from box other than iterating through all users or groups in an enterprise.

I can search for folders by name: https://api.box.com/2.0/search?query="Colab Folder 3"&scope=enterprise_content&type=folder

but not for groups, or users:

/api.box.com/2.0/search?query="Colab Group 3"&scope=enterprise_content&type=group

/api.box.com/2.0/search?query="[email protected]"&scope=enterprise_content&type=user

1

1 Answers

1
votes

If (and only if) you are an enterprise admin, you can do at least some of what you're asking.

Users

You can search for a specific user via the /users endpoint with a filter_term:

curl https://api.box.com/2.0/users?filter_term=foo42%40bar.com
-H "Authorization: Bearer ACCESS_TOKEN"

Groups

All of the /groups endpoints appear to be scoped to a single user, so I'm not sure there is an API method to find a group by name. However, if you know of a user that's in the group, you can use the method above to find that user and then fetch all of their groups:

curl https://api.box.com/2.0/users/USER_ID/memberships
-H "Authorization: Bearer ACCESS_TOKEN"

This should net you a pretty small list that can be filtered client-side.