Pages

Friday, 12 April 2019

What is the difference between PUT and POST method? REST API interview questions? Most asked RestAPI Automation Interview questions?



PUT vs POST : An Example

Let’s list down when to use POST and when to use PUT :

GET     /user-management/users: Get all users
POST     /user-management/users: Create a new user

GET     /user-management/users/{id} : Get the user information identified by "id"
PUT     /user-management/users/{id} : Update the user information identified by "id"


It is good practice to use:

 - PUT for UPDATE operations.
 - POST for CREATE operations.

  • PUT is Idempotent 

2 comments:

  1. Will PUT also create the resource if it not found on server?

    ReplyDelete
  2. Yes PUT is designed that way.

    ReplyDelete