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

5 comments on “cURL – PUT request examples

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

    Reply
    1. There is no standard for this. Normally, I use POST for create and PUT to update.

      Reply

Leave a Comment

Your email address will not be published. Required fields are marked *