linux curl
最编程
2024-10-07 19:34:57
...
0、基本参数
-
-X
或--request
: 指定请求方法,例如POST
。 -
-d
或--data
: 发送指定的数据作为POST请求的主体。数据可以是键值对的形式。 -
-H
或--header
: 添加自定义HTTP头部。可以多次使用以添加多个头部。 -
-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'