http status code for failed email send

假如想象 提交于 2020-01-13 19:52:05

问题


Consider an API call that creates a user. On success, the user is created and a confirmation email is sent. The response status code is 201.

If the user is not created, the response status code is 422.

What should the response status code be if user is created BUT sending the confirmation email failed?


回答1:


The core of the problem lies in mixing a RESTful resource creation and an RPC-style action. The creation of the user, in a RESTful world, would be the atomic operation and return 201 or 422 (or whatever error code you choose). Then the sending of the confirmation email might be another POST to /api/user/confirmationemailtask that then spins off the email process. When you combine the two you find the areas of ambiguity.

(moved comment to answer for posterity)



来源:https://stackoverflow.com/questions/30715604/http-status-code-for-failed-email-send

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!