Pregunta


I followed the basic guide to the Box API and I get 404 errors when I try to query any folder. (either root folder or one I created to prove "any")

Here is what I did, I have changed my API keys and email address etc.... (apologies for any oddities due to the markup/XML/JSON being pasted! I've tried to make it clear without spending ages reformatting everything)
First I generated my API key. Then :

curl  https://www.box.com/api/1.0/rest?action=get_ticket\&api_key=uoun62sm0baxyx53hdzgq9csc5fgJJJJ

<?xml version='1.0' encoding='UTF-8' ?>
<response><status>get_ticket_ok</status>
<ticket>kgof13pk1qq8ls6m2exi8vlupausJJJJ</ticket>
</response>

Then go to : https://www.box.com/api/1.0/auth/kgof13pk1qq8ls6m2exi8vlupausJJJJ

Login as a user (max@hotmail.com), then back to the command line :

curl https://www.box.com/api/1.0/rest?action=get_auth_token\&api_key=uoun62sm0baxyx53hdzgq9csc5fgJJJJ\&ticket=kgof13pk1qq8ls6m2exi8vlupausJJJJ

That gives me back an auth token :

<response><status>get_auth_token_ok</status>
<auth_token>9pqiii88obks0gg9kqtdcfq799bhJJJJ</auth_token>
<user><login>max@hotmail.com</login><email>max@hotmail.com</email>
<access_id>180987265</access_id><user_id>180987265</user_id><space_amount>5368709120</space_amount><space_used>68616595</space_used><max_upload_size>104857600</max_upload_size><sharing_disabled/></user></response>

So, I should be able to use my API key and auth token to get the contents of my root folder :

curl https://www.box.com/api/2.0/folders/FOLDER_ID \
-H "Authorization: BoxAuth api_key=uoun62sm0baxyx53hdzgq9csc5fgJJJJ&auth_token=9pqiii88obks0gg9kqtdcfq799bhJJJJ"


Returns :
{"type":"error","status":404,"code":"not_found","help_url":"","message":"Unknown Error","request_id":"8614183014fa10d5bcf63b"}

There is presumably something fundamental I'm doing wrong...?

Thanks, Max

¿Fue útil?

Solución

You need to replace 'FOLDER_ID' with '0' in the URI to get the contents of your root folder i.e.

curl https://www.box.com/api/2.0/folders/0 \
-H "Authorization: BoxAuth api_key=YOUR_API_KEY&auth_token=YOUR_AUTH_TOKEN"

Also, as a sidenote, it's generally never a good idea to post your auth token/api key to public forums such as this.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top