#!/bin/bash
定义 API 地址
API_URL=“https://api.example.com/users”
定义请求体
BODY=‘{“name”: “John”, “age”: 30}’
使用 curl 发送 POST 请求
curl -X POST -H “Content-Type: application/json” -d “$BODY” $API_URL
其中-h指定请求头,-d指定请求体
#!/bin/bash
定义 API 地址
API_URL=“https://api.example.com/users”
使用 curl 发送 GET 请求
curl $API_URL