I am trying to use Wget to access a RESTful interface, but I can not figure out how to do HTTP PUT with Wget. How can I do it? Or isn't it prossible?
Asked
Active
Viewed 1e+01k times
5 Answers
93
wget --method=PUT --body-data=<STRING>
This is a bit late, but at some point after the original post, they added a "--method" option. I'm not sure when it was added, but see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684189#24 for details.
John Henry
- 1,046
- 1
- 9
- 7
-
7This should be accepted answer. – Vanuan Oct 14 '16 at 02:17
-
4Should be accepted answer in 2014, 2016 or whenever. --method param wasn't avail in wget back in 2010 :( – Bernhard Döbler Nov 09 '16 at 13:09
-
16Not in busy box – Dmitry Minkovsky Jul 10 '17 at 21:04
-
Seems not working when using with authentication. I tried `wget --method=PUT` with digest access authentication but wget don't performs the authentication procedure like it do with standard GET request. – Joe Sep 22 '17 at 00:01
-
3--method still not available in centos 7. – David V. Jul 09 '19 at 11:15
-
6Note only with GNU wget, not busybox wget. – Ben Apr 03 '20 at 19:27
-
2Can also do `wget --method=PUT --body-file=
` if your body is a file. – meustrus May 13 '20 at 20:26
26
Wget can't do PUT. Use cURL instead, with -T.
Peter Mortensen
- 12,090
- 23
- 70
- 90
Ignacio Vazquez-Abrams
- 111,361
- 10
- 201
- 247
-
there's also a [wput utility](http://wput.sourceforge.net/) tho it seems limited to FTP. – quack quixote Apr 12 '10 at 08:19
-
16
22
Since this is REST interface, I think you'd want to use curl with -X PUT, like this:
curl -i -X PUT http://www.example.tld/rest/updateEntity/1234?active=false
Or if you need to "post" data from a file, like an XML:
curl -i -X PUT -H "Content-Type: application/xml; charset=utf-8" -d @"/tmp/some-file.xml" http://www.example.tld/rest/updateEntity
Sverre Marvik
- 371
- 1
- 3
6
For me following worked:
curl -T <file-path> <url>
For some reason when I did following it nothing happened (no error as well):
curl -X PUT -d <file-path> <url> (did not work)
hznut
- 61
- 1
- 2
-
2`-d` will send the data you entered on the command line, so it will try to PUT file path as text. – che Jan 08 '13 at 16:51
4
If you don't want to use a file as data, you can do the following.
curl -X PUT -d "something=blabla&somethingelse=blaha" http://www.example.com
Peter Mortensen
- 12,090
- 23
- 70
- 90
fredrik
- 141
- 3