How do I execute an HTTP PUT in bash?

If you really want to only use bash it actually has some networking support.

 echo -e "PUT /project?id=123 HTTP/1.1\r\nHost: website.com\r\n\r\n" > \
   /dev/tcp/website.com/80

But I guess you also want to send some data in the body?


With curl it would be something like

curl --request PUT --header "Content-Length: 0" http://website.com/project?id=1

but like Mattias said you'd probably want some data in the body as well so you'd want the content-type and the data as well (plus content-length would be larger)

Tags:

Bash

Put