cURL – PUT request examples

Example to use cURL -X PUT to send a PUT (update) request to update the user’s name and email.

Terminal

$ curl -X PUT -d 'name=mkyong&[email protected]' http://localhost:8080/user/100

If the REST API only accepts json formatted data, try this

Terminal

$ curl -X PUT -H "Content-Type: application/json" -d '{"name":"mkyong","email":"[email protected]"}' http://localhost:8080/user/100

References

  1. cURL official website
  2. cURL – POST request examples

mkyong

Founder of Mkyong.com, passionate Java and open-source technologies. If you enjoy my tutorials, consider making a donation to these charities.

5 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Annamalai T
8 years ago

Nice Tutorial

Venugopal
8 years ago

Very useful and informative. Thank you for sharing.

Matt
9 years ago

PUT is not for update – it is for creation, POST is for update (as the comment states update)

Drew Forbes
8 years ago
Reply to  Matt

In my opinion, a PUT can be used for a create if a second PUT with the same data would result in no change and no new record. Sending two POSTs with the same data should create two separate records.

You can find some great discussion on this question here: https://stackoverflow.com/questions/630453/put-vs-post-in-rest