2016-08-02 84 views
-1

我们如何在curl命令中添加JSON参数来获取数据? PS:我试图使用curl命令从某些源提取数据,但它需要在其中传递JSON参数。那么我将如何实现它?linux中的curl命令

回答

1

我想提的内容类型的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