Muhammad Imran Ansari
What is the difference between PUT and POST in REST?

What is the difference between PUT and POST in REST?

By Muhammad Imran Ansari in .NET on Oct 02 2024
  • Bimalshi Jayarathna
    Oct, 2024 20

    In the case of REST APIs, both PUT and POST methods are used for sending data to the server. PUT is responsible for updating an existing resource or replacing it; hence, it is idempotent-the result is the same whether executed once or multiple times. POST would create a new resource and is non-idempotent; repetitions of request may result in the creation of multiple resources.

    • 0
  • Ayush Gupta
    Oct, 2024 4

    PUT: Updates a resource at a specific URI. Idempotent—sending the same request multiple times results in the same outcome.eg-PUT api/users/123 {"name": "Jane Doe","email": "[email protected]" } here we are updating user with id =123.POST: Creates a new resource, usually without specifying the URI (the server decides). Non-idempotent—multiple requests can create multiple resources. eg-> POST api/users {"name": "Jane Doe","email": "[email protected]" } Here we will create a new user (resource ) in server and return the status 201.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS