How to send a PUT request under Windows using curl?

I need to send XML data through curl.exe under windows using a PUT request.

At the tip, I found:

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

What should I provide for <data>

+3
source share
3 answers

curling test 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 cygwin . It is a linux-like environment for windows, and also offers the "right" curl.

+14
source

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

, "This is" " " "" "" " ", Unix.

:

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

in windows you will need to put @ inside quotes for the file to be sent:

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

otherwise, you will get strange errors as it tries to use the contents of the file as a URL:

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

(uploadme.txt contains "upload me!")

+2
source

Source: https://habr.com/ru/post/1776482/


All Articles