0
votes

I try to lock a file via the API BOX but I encounted issue. I use the code provided the api documenation (https://developers.box.com/docs/ Lock and Unlock section) but the code does not work.

curl https://api.box.com/2.0/files/xxxxxx\
> -H "Authorization: Bearer xxxxxx" \
> -d "lock": null \
> -X PUT

and the return of the API:

{"type":"error","status":400,"code":"bad_request","context_info":{"errors":[{"reason":"invalid_parameter","name":"entity-body","message":"Invalid value 'lock:'. Entity body should be a correctly nested resource attribute name\/value pair"}]},"help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"Bad Request","request_id":"xxxxxxxxx"}curl: (6) Couldn't resolve host 'null'

I did the test by trying to locke a file : same problem.

Several questions:

  • Is that the lock function has already work? Do you know if box has changed its code ?

Any help is welcome :)

Nicolas

1

1 Answers

0
votes

I had an answer by Suppor team :

There was a typo in the docs. Please try the command again:

Lock:

curl https://api.box.com/2.0/files/FILE_ID
-H "Authorization: Bearer ACCESS_TOKEN"
-d '{"lock": {"type": "lock","expires_at": "2015-12-12T10:55:30-08:00","is_download_prevented": false}}'
-X PUT

Unlock:

curl https://api.box.com/2.0/files/FILE_ID
-H "Authorization: Bearer ACCESS_TOKEN"
-d '{"lock": null}'
-X PUT

https://support.box.com/hc/fr/requests/793456?flash_digest=c5350d2f104f3066b46cb83baa97c23dac863d2b