curl basic认证发form表单和Json数据

curl --basic -u -X -H -d

  • --basic:指定简单密码校验
  • -u:指定用户名和密码,格式:username:password
  • -X:指定请求方式
  • -H:指定header,例如:application/x-www-form-urleoded或者Content-Type: application/json
  • -d:指定参数

application/x-www-form-urleoded

注意:参数进行url编码

curl --basic -u iot:iot -X POST -H "application/x-www-form-urleoded" -d 'tslJson=%7B%22%5D%7D&productId=11529' http://192.168.0.1:8080/test

application/json

curl -H "Content-Type: application/json" -X POST -d '{"user_id": "123", "coin":100, "success":1, "msg":"OK!" }' http://192.168.0.1:8080/test

おすすめ

転載: blog.csdn.net/qq_30038111/article/details/113359927