[英]HTTP status code in case of failure scenario for a REST API which does SMTP connection test
What should be right http status code which we should use in REST response for an API which does SMTP configuration test and send test mail for failure scenario like SMTP configuration is not correct or Authentication Issue with smtp server etc. 应该正确的http状态代码,我们应该在REST响应中使用API进行SMTP配置测试并针对SMTP配置失败情况发送测试邮件,例如SMTP配置不正确或smtp服务器的身份验证问题等。
Any suggestions. 有什么建议么。
I would suggest returning 200 OK with a message about failure in response body or header. 我建议返回200 OK,并带有有关响应正文或标头失败的消息。 If you put it 400 (BAD_REQUEST) or some other error code, you wouldn't know if the service was down or there was something else wrong with the code, which caused the bad response.
如果将其设置为400(BAD_REQUEST)或其他错误代码,您将不知道服务是否关闭或该代码是否存在其他错误,从而导致响应错误。
If you do want to check the service availability, I'd suggest 417 (expectation failed) 如果您确实要检查服务的可用性,建议您输入417(预期失败)
Not a big expert of SMTP but I would suggest you to google for the list of SMTP status and then map those SMTP status to HTTP status code . 不是SMTP的专家,但我建议您用谷歌搜索SMTP状态列表,然后将这些SMTP状态映射到HTTP状态代码 。 Most of the time for HTTP status, you have 3 main categories grouped by status code (ranges):
在大多数情况下,HTTP状态中,您有3个主要类别,按状态代码(范围)分组:
I don't really know if there is a relation between SMTP and HTTP code status. 我真的不知道SMTP和HTTP代码状态之间是否存在关系。 In this case it is your own choice to choose which status code you will map together, and then return the good HTTP code result.
在这种情况下,您可以选择要一起映射的状态代码,然后返回良好的HTTP代码结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.