curl命令

1 使用curl命令以post方式向服务器发送xml格式的数据

echo '<?xml version …>' | curl -X POST -H 'Content-type:text/xml' -d @- http://10.206.30.32:8081/loginregistration/register

示例2:

curl -X POST -H 'Content-type:application/xml' -d @planet http://192.168.43.2:8888/rest2/rest2/xmls/post_planet

planet里面示一个xml文件,放在curl同一目录下。

2 使用curl命令以post方式向服务器发送json格式的数据

curl -X POST -H 'Content-type:application/json' -d '{"name":"Agamemnon","age":32}' http://192.168.43.2:8888/rest3/rest3/json/post_json

注意:-d 后面接的json数据的最外层要用单引号。

原文地址:https://www.cnblogs.com/hustdc/p/8452585.html