Got "Bad Request" as parent is required using API Call in API Reference.

Highlighted
New Contributor

Got "Bad Request" as parent is required using API Call in API Reference.

Hi,

 

I want to try using the API Call in this website API reference for creating new folder

but instead I got the Bad Request saying that parameter is missing due to parent is required.

In developer mode, the console keep showing that 

 

Click to expand
Request.js:37 POST https://api.box.com/2.0/folders/ 400 (Bad Request)

Is there anyway I can successfully do the API call via the API site ?  

3 REPLIES 3
Highlighted
Box Employee

Re: Got "Bad Request" as parent is required using API Call in API Reference.

Click to expand
Hi @Y-Sano  - You likely tried to create a folder without specifying a parent folder id. If you want to create a folder in your 'root' - i.e. the view you see when you first log in, you use id = 0.  For example:

curl --location --request POST 'https://api.box.com/2.0/folders' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer mytoken' \
--data-raw '{
  "name": "A New Folder",
  "parent": {
    "id": "0"
  }
}'​


I suggest you check out the Postman collection as it has many examples of properly formatted API calls

https://developer.box.com/guides/tooling/postman/

Highlighted
New Contributor

Re: Got "Bad Request" as parent is required using API Call in API Reference.

Thank you for your answer. I did try setting root folder id already but it's still kept showing the 400.

 

無題.png

 

 

 

無題2.png

 

 

Highlighted
Box Employee

Re: Got "Bad Request" as parent is required using API Call in API Reference.

Hey @Y-Sano - It looks like this may be a problem with our documentation site. I was able to reproduce the same error and it looks like the browser is not actually sending the parent folder id when it sends the API request. I've logged a request with our developer relations team to look into this, but in the mean time I suggest you use our Postman collection to experiment with the API.

 

https://developer.box.com/guides/tooling/postman/