Box Rest APIv2: Move File or Folder

2019-06-28 04:16发布

问题:

There is a move operation in v1 API.

But is there any equivalent for v2 Rest API? There is copy function in V2, I tried to replace it as move but no love, with operation not permitted error or something like that:

curl https://api.box.com/2.0/files/FILE_ID/move \
  -H "Authorization: BoxAuth api_key=API_KEY&auth_token=AUTH_TOKEN" \
  -d '{"parent": {"id" : FOLDER_ID}}' \
  -X MOVE

回答1:

You can do this by updating the parent of the item via a PUT request i.e.

curl https://api.box.com/2.0/files/FILE_ID \
    -H "Authorization: BoxAuth api_key=API_KEY&auth_token=AUTH_TOKEN" \
    -d '{"parent": {"id": "THE_NEW_PARENT_ID"}}' \
    -X PUT


标签: box-api