Main Tutorials

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

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
5 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Annamalai T
6 years ago

Nice Tutorial

Venugopal
6 years ago

Very useful and informative. Thank you for sharing.

Matt
6 years ago

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

Drew Forbes
6 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