What is difference between web api post and put
-
i searched google a lot still got no good explanation with example. mostly all write up is saying put is idempotent and post is not but i need a sample code which discuss or show idempotency of put method. so my request anyone can explain the put idempotency with example code or redirect me to right article link which discuss the same with example code. thanks
tbhattacharjee
-
i searched google a lot still got no good explanation with example. mostly all write up is saying put is idempotent and post is not but i need a sample code which discuss or show idempotency of put method. so my request anyone can explain the put idempotency with example code or redirect me to right article link which discuss the same with example code. thanks
tbhattacharjee
-
i searched google a lot still got no good explanation with example. mostly all write up is saying put is idempotent and post is not but i need a sample code which discuss or show idempotency of put method. so my request anyone can explain the put idempotency with example code or redirect me to right article link which discuss the same with example code. thanks
tbhattacharjee
PUT
- RFC-2616 clearly mention that PUT method requests for the enclosed entity be stored under the
supplied Request-URI. If the Request-URI refers to an already existing resource – an update operation
will happen, otherwise create operation should happen if Request-URI is a valid resource URI.
PUT /questions/{question-id} - PUT method is idempotent. So if you send retry a request multiple times, that should be equivalent to
single request modification. - Use PUT when you want to modify a singular resource which is already a part of resources collection.
PUT replaces the resource in its entirety. Use PATCH if request updates part of the resource. - Generally, in practice, always use PUT for UPDATE operations.
POST
- The POST method is used to request that the origin server accept the entity enclosed in the request
as a new subordinate of the resource identified by the Request-URI in the Request-Line. It
essentially means that POST request-URI should be of a collection URI. POST /questions - POST is NOT idempotent. So if you retry the request N times, you will end up having N resources with
N different URIs created on server. - Use POST when you want to add a child resource under resources collection.
- Always use POST for CREATE operations.
- RFC-2616 clearly mention that PUT method requests for the enclosed entity be stored under the