問題:
I'm building an application with a REST-based API and have come to the point where i'm specifying status codes for each requests. 我正在使用基於REST的API構建應用程序,而且到了我爲每一個請求指定狀態代碼的地步。 html
What status code should i send for requests failing validation or where a request is trying to add a duplicate in my database? 對於驗證失敗的請求,或者請求試圖在數據庫中添加劇復項的狀況,我應該發送什麼狀態代碼? 數據庫
I've looked through http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html but none of them seems right. 我已經瀏覽了http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html,可是彷佛都不對。 app
Is there a common practice when sending status codes? 發送狀態代碼時是否有慣例? ui
解決方案:
參考一: https://stackoom.com/question/DnvS/驗證失敗或重複無效的REST-HTTP狀態代碼參考二: https://oldbug.net/q/DnvS/REST-HTTP-status-codes-for-failed-validation-or-invalid-duplicate