4

i'm trying to connect ti a web api service, box-api, and following the tutorial i have to type this command to fetch a folder in the user content:

 curl https://api.box.com/2.0/folders/FOLDER_ID/items?limit=2&offset=0 -H "Authorization: Bearer ACCESS_TOKEN"

I tryied to connect from the command line to test the command but it keep complaining about the -H or the --header command saying that it doesn exist:

 -bash: -H: command not found
 -bash: --header: command not found

but when i type curl --help the command is in the manual:

 -H, --header LINE   Custom header to pass to server (H)

I'm confused, what should i do to connect to this site and get the JSON content? Thanks

Sabuj Hassan
  • 38,281
  • 14
  • 75
  • 85
softwareplay
  • 1,379
  • 4
  • 28
  • 64

2 Answers2

12

Your url has & sign. and this is making end of command on there(and running at background). You can remove this error by using quotes around. Like this

curl "https://api.box.com/2.0/folders/FOLDER_ID/items?limit=2&offset=0" -H "Authorization: Bearer ACCESS_TOKEN"

Hope this helps.

Sabuj Hassan
  • 38,281
  • 14
  • 75
  • 85
2

There seem to be two problems:

  1. The '&' in the middle of the URL passed to curl,
  2. The order of the statements. The curl manual reports a different order for the statements. Example:

    curl -H "Authorization: Bearer AUTH_KEY" "https://api.box.com/2.0/folders/0/items?limit=2&offset=0"
    

This should be the complete solution.

softwareplay
  • 1,379
  • 4
  • 28
  • 64