We have a situation where we have 2 users, UserA and UserB. I want to transfer all the files and folders of UserB to UserA.
We are using collaborations API to perform this task. But getting following error
{"type":"error","status":404,"code":"not_found","context_info":{"errors":[{"reason":"invalid_parameter","name":"role","message":"Invalid value 'Owner'. 'role' with value 'Owner' not found"}]},"help_url":"http://developers.box.com/docs/#errors","message":"Not Found","request_id":"304354248562a743910984"}
I get a valid response when I pass anything apart from "owner" as role in request. I don't know what is wrong with "owner" role.
Here is the request
POST https://api.box.com/2.0/collaborations/ HTTP/1.1
As-User: 254598270
Authorization: Bearer UPSUE228kXGuDBGzy07G5fGxIrDL1QDj
Content-Type: text/plain; charset=utf-8
Host: api.box.com
Content-Length: 108
Expect: 100-continue
Accept-Encoding: gzip, deflate
{"item":{"id":"5092905410","type":"folder"},"accessible_by":{"id":"254608030","type":"user"},"role":"owner"}
I think the documentation might be wrong. Specifying an "owner" role in a collaboration doesn't really make sense given how collaborations work.
However, the move user's folder endpoint might be what you're looking for. It allows you to move the entire root folder of one user into another user's account. Here's an example cURL request:
curl https://api.box.com/2.0/users/USER_ID/folders/FOLDER_ID \
-H "Authorization: Bearer ACCESS_TOKEN" \
-d '{"owned_by": {"id": "USER_ID"}}' \
-X PUT
Note that only the root folder is supported right now (which is folder ID 0). Fortunately, it looks like that's the folder you're trying to move.