4 ms·
> - /organizations/:organizationId/blogs, with ... POST to ... create a blog for an organisation Be careful with that! If there's a network error sending the r
by adrianmsmith 4y ago
> - /organizations/:organizationId/blogs, with ... POST to ... create a blog for an organisation
Be careful with that! If there's a network error sending the response, the blog will have been created and you won't have received the ID on the client.
In a distributed environment (such as REST) it's better to make all calls idempotent. Choose an ID on the client e.g. generate a random UUID. Then do a PUT to ..../:id. That will update the blog if it exists or create it if not. If the create call fails, you can just retry it (with the same ID), if the request previously failed and it never got created it'll create it now, and if the response previously failed and it did get created but you never got the successful response it'll get "edited" to the same values as it already has.