开发者

How to post PUT request under the Windows using curl?

I need to post XML data via curl.exe under windows using PUT request.

In the curl help I found:

-d/--data <data>   HTTP POST data (H)

What sho开发者_StackOverflowuld I supply for <data>?


curl sample calls

# with inlining plain data
curl -X PUT -d "payload" http://localhost
# referrring file
curl -X PUT -d @myXmlFile.xml http://localhost

If your windows curl-port does not support it go for cygwin. It is a linux-like environment for windows and also offers "a proper" curl.


In windows, if a double-quoted argument itself contains a double quote character, the double quote must be doubled.

For example, enter 'This is "quoted" payload' as "This is ""quoted"" payload" which is very different than in Unix.

Example:

curl -X PUT -d "This is ""quoted"" payload" http://localhost


in windows you'll need to put the @ inside the quotes for the file you're sending:

curl -XPUT --data-binary "@uploadme.txt"

otherwise you'll get weird errors as it tries to use the content of the file as the url:

curl: (6) Couldn't resolve host 'upload'
curl: (6) Couldn't resolve host 'me!'

(uploadme.txt contains "upload me!")


on Windows CMD, curl refers to C:\Windows\System32\curl.exe so you can use

curl -X PUT -d "payload" http://localhost

instead on Windows PowerShell curl refers to Invoke-WebRequest so it is not working with curl syntax. you can use curl.exe on PowerShell to call C:\Windows\System32\curl.exe so it will solve the issue.

curl.exe -X PUT -d "payload" http://localhost
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜