|
|
@ -1,42 +1,6 @@
|
|
|
|
# HTTP Responses & Status Codes
|
|
|
|
# HTTP Responses & Status Codes
|
|
|
|
|
|
|
|
|
|
|
|
# HTTP Responses
|
|
|
|
## Check http request format from frontend-basics
|
|
|
|
|
|
|
|
|
|
|
|
* HTTP responses have the following format:
|
|
|
|
|
|
|
|
* Status line: HTTP version, status code, reason phrase
|
|
|
|
|
|
|
|
* HTTP/1.1 200 OK
|
|
|
|
|
|
|
|
* Headers (optional)
|
|
|
|
|
|
|
|
* Date: Mon, 07 Sep 2020 08:39:33 GMT
|
|
|
|
|
|
|
|
* Content-Type: application/json
|
|
|
|
|
|
|
|
* Body (optional)
|
|
|
|
|
|
|
|
* {
|
|
|
|
|
|
|
|
* "date": "2020-09-08T11:39:34.2837813+03:00",
|
|
|
|
|
|
|
|
* "temperatureC": 11,
|
|
|
|
|
|
|
|
* "temperatureF": 51,
|
|
|
|
|
|
|
|
* "summary": "Cool"
|
|
|
|
|
|
|
|
* }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Status Codes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* The status line of HTTP a response sent by an API should accurately describe the status of what has happened on the server after each request:
|
|
|
|
|
|
|
|
* Did the operation succeed? (2xx status codes)
|
|
|
|
|
|
|
|
* Was there an error with the request, i.e. the request line was malformed, or the server doesn't support it (4xx status codes)
|
|
|
|
|
|
|
|
* Did a server side exception occur? (5xx status codes)
|
|
|
|
|
|
|
|
* This is never the client's fault
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Status Codes (continued)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Your APIs should use the following status codes for responses to CRUD operations:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| __2xx SUCCESS__ | __4xx CLIENT ERROR__ | __5xx SERVER ERROR__ |
|
|
|
|
|
|
|
|
| :-: | :-: | :-: |
|
|
|
|
|
|
|
|
| 200 - OK | 400 - Bad Request | 500 - Internal Server Error |
|
|
|
|
|
|
|
|
| 201 - Created | 401 - Unauthorized | |
|
|
|
|
|
|
|
|
| 204 - No Content | 403 - Forbidden | |
|
|
|
|
|
|
|
|
| | 404 - Not Found | |
|
|
|
|
|
|
|
|
| | 409 - Conflict | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[https://restfulapi.net/http-status-codes/](https://restfulapi.net/http-status-codes/)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ASP.NET Status Codes
|
|
|
|
# ASP.NET Status Codes
|
|
|
|
|
|
|
|
|
|
|
|