我们如何在curl命令中添加JSON参数来获取数据? PS:我尝试使用curl命令从某些源获取数据,但它需要在其中传递JSON参数。那么我将如何实现它呢?
最佳答案
我认为将内容类型提及为 json 并传递数据会做正确的事情
curl -H "Content-Type: application/json" -d '{"key1":"value1","key2":"value2"}' http://domain.com/rest/path/here
以上适用于 GET 方法,适用于 POST 方法
curl -H "Content-Type: application/json" -X POST -d '{"key1":"value1","key2":"value2"}' http://domain.com/rest/path/here
关于linux - Linux中的curl命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38716850/