自学内容网 自学内容网

linux之curl

0、基本参数

  1. -X--request: 指定请求方法,例如 POST

  2. -d--data: 发送指定的数据作为POST请求的主体。数据可以是键值对的形式。

  3. -H--header: 添加自定义HTTP头部。可以多次使用以添加多个头部。

  4. -F--form: 用于发送表单数据,特别是文件上传。

1、发送post请求

curl -X POST "http://xxx.xxx.x.xxx:xxxx/api/query/template" \
-H "Content-Type: application/json" \
-d '{
    "user_id": 223,
    "type": 1,
    "sign": "4ECD47349E77397B6FD0184C300CD8B9"
}'
curl -X 'POST' \
  'http://xxx.xxx.x.xxx:xxxx/api/file/upload?scene_id=1&session_id=1213123131' \
  -H 'accept: application/json' \
  -H 'Content-Type: multipart/form-data' \
  -F 'file=@tmplt01.xlsx;type=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'

2、发送get请求

curl -X 'GET' \
  'http://xxx.xxx.x.xxx:xxxx/api/get_file/1111.xlsx' \
  -H 'accept: application/json'


-------------------------------------------------------------------


curl -X 'GET' \
'http://xxx.xxx.x.xxx:xxxx/api/chat/history/a5874547-6aa1-4607-a64c-3333635886cb' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjYyMTg2ODcsInN1YiI6IjE1MDcxMjA3NDUyIn0.RVeIW74ETqoyxbjLmVzEelLzE-8xto-CLD3mryCLGEw'


原文地址:https://blog.csdn.net/qq_41081716/article/details/142725138

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!