我正在开发一个调用 RESTful api 的程序。 api 的所有文档都是 cURL 命令,但我不会制作 cURL 命令,因此我需要翻译它们并以不同的方式发出请求。这是他们为我想要进行的查询类型提供的示例代码。
curl -u '{userEmail}:{userApiToken}' -v -X GET -H 'Content-Type: application/xml' -o 'result.xml' -d '<request><layout>1</layout><searchmode>Cany</searchmode><searchvalue>aaron</searchvalue><filtermode></filtermode><filtervalue></filtervalue><special></special><limit>100</limit><start></start><sortfield></sortfield><sortdir></sortdir></request>' https://secure.website.com/contacts `
我已经阅读了 cURL 文档并了解除 -d 之外的所有标志。我知道它的参数是搜索参数的 xml,但是 GET cURL 上的 -d 是什么意思?
谢谢
最佳答案
-d
指定请求的主体。来自手册页:
-d, --data (HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button. This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded. Compare to -F, --form.
-d, --data is the same as --data-ascii. --data-raw is almost the same but does not have a special interpretation of the @ character. To post data purely binary, you should instead use the --data-binary option. To URL-encode the value of a form field you may use --data-urlencode.
有趣的是,您使用的服务将 GET 与请求主体结合使用,如 here, it is possible but unwanted 所述.
例如;允许代理人移走尸体。但是只要你和他们的服务器之间没有机器,它就可以工作;并且他们可能拥有允许他们解读 body 的软件。
关于xml - 这个 cURL 命令中的 -d 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32701551/