我正在使用一个网页界面,允许我通过卷曲请求发布内容.
示例帖子如下所示:
<status>A note</status>
Run Code Online (Sandbox Code Playgroud)
但每当我尝试发送它时,它似乎都不接受XML
curl http://website.com/update -d '<?xml version="1.0" encoding="UTF-8"?><status>test</status>' -H 'Accept: application/xml' \ -H 'Content-Type: application/xml' -u username:password
Run Code Online (Sandbox Code Playgroud)
我可以做任何其他类型的请求,只是发送这个XML似乎不起作用,我在这里做错了什么?
要使用curl
你发送数据(xml,json,text等),必须使用POST方法并添加--data-urlencode
参数,如下图所示:
curl -X POST http://website.com/update \
--data-urlencode xml="<status>A note</status>" \
-H 'Accept: application/xml' \
-H 'Content-Type: application/xml' \
-u username:password
Run Code Online (Sandbox Code Playgroud)
要么
curl -X POST http://website.com/update \
--data-urlencode "<status>A note</status>" \
-H 'Accept: application/xml' \
-H 'Content-Type: application/xml' \
-u username:password
Run Code Online (Sandbox Code Playgroud)
如果你想通过GET发送我认为你必须在调用curl
命令之前编码字符串
归档时间: |
|
查看次数: |
14466 次 |
最近记录: |