Curl Rest Examples:

GET

curl -X GET -H "Content-Type:application/xml" "http://localhost:8080/some/path/505?username=foo&password=bar"

Create

curl -X PUT -H "Accept: *" -d @someFile.xml "http://localhost:8080/some/path?username=foo&password=bar"

Create or Update

curl -X POST -H "Content-Type:application/xml" -d @someFile.xml "http://localhost:8080/some/path/save?username=foo&password=bar"

Delete

curl -X DELETE -H 'Content-Type:application/xml' -d @someFile.xml "http://localhost:8080/some/path?username=foo&password=bar"

Upload file

curl -X PUT -H 'Content-Type:multipart/form-data' -F "someFile.csv=@someFile.csv;type=text/csv" "http://localhost:8080/some/path/505?username=foo&password=bar" --verbose

Download file

curl -H "Accept: *" "http://localhost:8080/some/path/506?username=foo&password=bar" --O "foo.bar" --verbose

PUT data with linefeeds

Example is consul configuration

curl -X PUT -d $'somedata # some comment \n more data \n' http://localhost:8500/v1/kv/somekey

Comments

Popular posts from this blog

Sites, Newsletters, and Blogs

Oracle JDBC ReadTimeout QueryTimeout