天天看點

curl指令模拟json格式的post請求

#curl指令模拟json格式的post請求

測試接口時,如果是get請求直接在浏覽器上附上參數就可

例如:​​https://www.baidu.com/baidu?tn=monline_3_dg&ie=utf-8&wd=浪丶蕩​​​

而post請求可以利用Linux的curl指令這樣模拟

curl -H "Content-Type:application/json" -X POST --data '[{"index":["*"],"preference":"1503652289983","ignore_unavailable":"true"},{"sort":[{"timestamp":{"order":"desc"}}],"query":{"must_not":[],"bool":{"must":[{"query_string":{"query":"cluster"}},{"range":{"timestamp":{"gte":"1503667558137","lte":"1503667558137"}}}]}},"from":"0","size":"500","version":"true"}]' http://212.35.247.184:18080/      

json串内層參數需要符合json格式規範,最後的ip是目的主機的位址和端口号