3 ms·
> If you want or need your API to be idempotent, use POST for creation and updating. This bit is wrong. First, implementing idempotence for your endpoint is U
by jholman 5y ago
> If you want or need your API to be idempotent, use POST for creation and updating.
This bit is wrong.
First, implementing idempotence for your endpoint is UP TO YOU, no matter what method you use. For some methods (though not POST), idempotence is a requirement for spec compliance, not a thing HTTP somehow magically gives you.
Second, although some methods (notably PUT and DELETE) are required to be idempotent (though that's really kind of a freebie when you read the rest of the requirements for those methods), you're welcome to implement idempotent endpoints behind a POST.
> If you use POST or PUT to update...
You're correct about PUT, but POST has no such requirement. You can send anything you want in a POST, because you may legally define whatever semantics you want on the fictitious purpose of the entity you're including.
Circling back, PUT and PATCH give no advantages over POST. :)