我正在尝试连接 Web API 服务,box-api 并按照教程进行操作,我必须键入以下命令才能获取用户内容中的文件夹:
curl https://api.box.com/2.0/folders/FOLDER_ID/items?limit=2&offset=0 -H "Authorization: Bearer ACCESS_TOKEN"
我尝试从命令行连接以测试命令,但它一直抱怨-H
或--header
命令说它不存在:
-bash: -H: command not found
-bash: --header: command not found
但是当我键入 curl --help 时,命令在手册中:
-H, --header LINE Custom header to pass to server (H)
我很困惑,我应该怎么做才能连接到这个网站并获取 JSON 内容?谢谢
您的网址有&
符号。 这是在那里结束命令(并在后台运行)。您可以通过在周围使用引号来消除此错误。喜欢这个
curl "https://api.box.com/2.0/folders/FOLDER_ID/items?limit=2&offset=0" -H "Authorization: Bearer ACCESS_TOKEN"
希望这有帮助。
似乎有两个问题:
- URL 中间的"&"传递给 curl,
-
语句的顺序。curl 手册报告语句的不同顺序。例:
curl -H "Authorization: Bearer AUTH_KEY" "https://api.box.com/2.0/folders/0/items?limit=2&offset=0"
这应该是完整的解决方案。