curl模擬post json或post xml文件


問題描述:

  Linux用命令模擬接口,對接口判斷!post文件xml/json

問題解決:

  cur很好地解決此問題!

#curl post xml報文
echo 'xxxx  '| curl -X POST -H 'Content-type:text/xml' -d @-  http://1.1.1.1:8081/loginregistration/register

cat 1.xml | curl -X POST -H 'Content-type:text/xml' -d @-   http://1.1.1.1::8081/httpInvokeServlet
注解: xxxx是xml報文內容  1.xml 報文文件   @- 讀取管道符內容

#curl post json 報文
curl  -H "Content-Type:application/json" -X POST --data 'xxxx' http://1.1.1.1:18080/

cat 1.json | curl -H "Content-Type:application/json" -X POST -d @- http://1.1.1.1:8081/httpInvokeServlet

注解: xxxx是json報文內容  1.json 報文文件   @- 讀取管道符內容


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM