问题
I want to add a collaboration using the v2 api - but it requires a user id. How do I get the user id if all I have is the login name?
回答1:
When adding a collaborator, you can send either the user id or the user's email address:
i.e. both
curl https://api.box.com/2.0/collaborations \-H "Authorization: Bearer ACCESS_TOKEN" \
-d '{"item": { "id": "FOLDER_ID", "type": "folder"}, "accessible_by": { "id": "USER_ID"}, "role": "editor"}' \
-X POST
and
curl https://api.box.com/2.0/collaborations \-H "Authorization: Bearer ACCESS_TOKEN" \
-d '{"item": { "id": "FOLDER_ID", "type": "folder"}, "accessible_by": { "login": "USER_EMAIL"}, "role": "editor"}' \
-X POST
will work. In the case of the second example, the user doesn't have to have a Box account.
http://developers.box.com/docs/#collaborations-add-a-collaboration
来源:https://stackoverflow.com/questions/14046216/using-the-v2-box-api-how-do-i-get-a-user-id