我正在使用这个 curl 行,以便触发对我的服务器的 POST 请求:
curl --data "item=my_item&is_done=true" 127.0.0.1:5000/convert
如何转换卷曲线,以发送相同的参数,但通过 JSON?
答案 0 :(得分:1)
您可以使用以下命令
curl -d ‘{“item”: “my_item”, “is_done”: “true”}’ -H “Content-Type: application/json” -x POST 127.0.0.1:5000/convert
或
如果您想在文件 abcd.json 中共享参数,则
curl -d “@abcd.json” -H “Content-Type: application/json” -x POST 127.0.0.1:5000/convert