What is the difference between PUT and POST methods in REST?

What is the difference between PUT and POST methods in REST?

A) PUT is idempotent, POST is not
B) POST is idempotent, PUT is not
C) PUT retrieves data, POST deletes data
D) POST updates resources, PUT retrieves resources

Answer:

A) PUT is idempotent, POST is not

Explanation:

The key difference between PUT and POST methods in REST is that PUT is idempotent, while POST is not. Idempotence means that multiple identical requests should have the same effect as a single request.

PUT is typically used to update an existing resource or create a new resource if it does not already exist. Sending the same PUT request multiple times will result in the same outcome as sending it once. In contrast, POST is used to create a new resource, and sending the same POST request multiple times can result in multiple resources being created.

Reference links:

https://www.javaguides.net/p/rest-api-tutorial.html

Leave a Comment

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

Scroll to Top