使用curl命令发送POST请求并带请求json
本次测试使用测试站点

# https://httpbin.org/
  1. 使用Postman测试
  2. 使用curl命令测试
# # curl -X POST  -H "accept: application/json" --data '{"test":"test"}' "https://httpbin.org/post"
{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {
    "{\"test\":\"test\"}": ""
  }, 
  "headers": {
    "Accept": "application/json", 
    "Content-Length": "15", 
    "Content-Type": "application/x-www-form-urlencoded", 
    "Host": "httpbin.org", 
    "User-Agent": "curl/7.29.0", 
    "X-Amzn-Trace-Id": "Root=1-66011abd-0ab3b6f155eb060b31f6f27d"
  }, 
  "json": null, 
  "origin": "113.89.235.9", 
  "url": "https://httpbin.org/post"
}

命令解析

# curl命令
curl 
# 为POST请求
-X POST
# 接受json格式
# -H "accept: application/json" 
# 传递json数据
# --data '{"test":"test"}' 
# 请求站点地址
# "https://httpbin.org/post"