Safe requests can be cached by a client, but unsafe requests cant.
Always use post puta for create operations.The server does the business, returns the response and stores it against the agreed action URI.PUT and delete are idempotent, post is not.And we can start to demand, and enforce!, responsible behaviour from clients: repeat your requests as much as you create like, but don't go meaning generating a new action until you're in possession of a definitive result from the existing one.If you think this is a huge change to implement, I can tell you from experience that it's not.It leads to broken friendships, rainy picnics, and sad-looking kittens.This is what were doing when we PUT to /api/programmers/CowboyCoder.Post is NOT idempotent.This is not idempotent.Post and Non-Idempotency, one last post thing.We take a weakness, the propensity for clients to repeat a request any time they don't understand the response, and turn it into a strength :- before telling me this is not restful, please consider the numerous ways in which rest principles are respected.This results in an update because CowboyCoder already exists.Back at the client, you then have to jump through hoops to interpret madre these errors, refetch, revalidate and repost. Use PUT when you want to modify a singular resource which is already a part of resources collection.
Use PUT when you can update a resource completely through a specific resource.
According to ME, real-life networks are unreliable.
Readers new to this topic will be struck meaning by madre the endless discussion about what you should do, and the relative create absence of lessons from create experience.Http verbs are used appropriately.Lets try to solve puta the puzzle when to use PUT or post.Responses to this method are not cacheable, unless the response includes appropriate Cache-Control or Expires header fields.Http currently gives you a minute or two to respond definitively.GET /device-management/devices : Get all devices.Ok, yes, logs will be written and analytics collected, but safe methods should never modify any real data.Now you can see why it seems right to say that post creates resources and PUT updates them.PUT method is idempotent.Will it handle the rise of smartphones and flaky mobile connections?The API stays discoverable, albeit with a little change in semantics.So if you retry the request N times, you will end up having N resources with N different URIs created on server.Idempotent, within meaning the unsafe methods, we have to talk about the famous term: idempotency.
The post method is used to request that the create 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.
Being safe affects caching.