How can I do a HTTP PUT with Wget?

92,529

Solution 1

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.

Solution 2

Wget can't do PUT. Use cURL instead, with -T.

Solution 3

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

Solution 4

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)

Solution 5

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
Share:
92,529

Related videos on Youtube

Jonas
Author by

Jonas

I'm a Computer Science student.

Updated on September 17, 2022

Comments

  • Jonas
    Jonas over 1 year

    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?

  • quack quixote
    quack quixote about 14 years
    there's also a wput utility tho it seems limited to FTP.
  • che
    che over 11 years
    -d will send the data you entered on the command line, so it will try to PUT file path as text.
  • John Henry
    John Henry over 9 years
    Wget can now do PUT using --method.
  • Vanuan
    Vanuan over 7 years
    This should be accepted answer.
  • Bernhard Döbler
    Bernhard Döbler over 7 years
    Should be accepted answer in 2014, 2016 or whenever. --method param wasn't avail in wget back in 2010 :(
  • Dmitry Minkovsky
    Dmitry Minkovsky almost 7 years
    Not in busy box
  • Joe
    Joe over 6 years
    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.
  • David V.
    David V. almost 5 years
    --method still not available in centos 7.
  • Ben
    Ben about 4 years
    Note only with GNU wget, not busybox wget.
  • meustrus
    meustrus about 4 years
    Can also do wget --method=PUT --body-file=<FILENAME> if your body is a file.