| 用途 | POST 请求 / 表单 / JSON / 文件上传 |
|---|---|
| 语法 | curl [-d|-F|--data-urlencode] ... |
| 要点 | -d 三次可传多段;@file 读内容;@- 读 stdin |
常用示例
常用示例
curl -sS -d 'name=ops&level=1' https://api.example.com/items
curl -sS --data-urlencode 'q=hello world & more' -G https://api.example.com/search
curl -sS -H 'Content-Type: application/json' -d '{"name": "web01", "port": 8080}' https://api.example.com/items
curl -sS -F 'file=@/tmp/backup.tar.gz' https://api.example.com/upload-d 自动把方法变成 POST;需要 PUT/DELETE 用 -X PUT / -X DELETE 显式指定。