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
Nice Tutorial
Very useful and informative. Thank you for sharing.
PUT is not for update – it is for creation, POST is for update (as the comment states update)
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
There is no standard for this. Normally, I use POST for create and PUT to update.