Most of the time, when we are designing a web API, we do not consider much what status codes to return. Some codes are returning to the client by default by the API but it is essential that we control what codes that get returned to the client.
This is essential when we are designing a generic APIs where we do not know who would connect to the APIs to get a service. Following are some common HTTP status codes that we should return for common HTTP methods.
This is essential when we are designing a generic APIs where we do not know who would connect to the APIs to get a service. Following are some common HTTP status codes that we should return for common HTTP methods.
HTTP Verb
|
Applicable
Status codes
|
GET
|
200-Ok, 404- Not Found, 400-
Bad Request , 500- Internal Server error
|
POST
|
201- Created , 400- Bad Request , 500- Internal Server error
|
DELETE
|
204- No Content, 404- Not Found, 400- Bad Request , 500- Internal Server
error
|
PUT
|
200-Ok, 404- Not Found, 400-
Bad Request , 500- Internal Server error
|
PATCH
|
200-Ok, 404- Not Found, 400-
Bad Request , 500- Internal Server error
|
General
|
401- Unauthorized, 403 Forbidden, 405 Method not allowed
|
No comments:
Post a Comment