http reply requests code example
Example 1: http status codes
2xx : SUCCESS
200 OK : success
201 CREATED : successfully added data
204 NO-CONTENT successfully updated or deleted
3xx : REDIRECTION
304 NOT MODIFIED:
4xx : CLIENT SIDE ERROR
400 BAD REQUEST : bad data being sent
401 UNAUTHORIZED :
403 FORBIDDEN :
404 NOT FOUND : the resource does not exists at that location
405 METHOD NOT ALLOWED :
DELETE /api/spartans -->> 405 error
406 NOT ACCEPTABLE
415 Unsupported Media type
if you forget to specify the Content-Type
of Post request body, it will see it as plain text
and it will throw this error if it does not support
5xx : Server side error
500 internal service error
If the server do not have any mapping of the url
requested to handle the action -->> 500
503 SERVICE UNAVAILABLE :
504 GATEWAY TIMEOUT :
Example 2: 200 error code
The HTTP 200 OK success status response code indicates that the request has succeeded. A 200 response is cacheable by default. The meaning of a success depends on the HTTP request method: GET : The resource has been fetched and is transmitted in the message body.
from developer.mozilla.org
Example 3: http response
resource HTTP response method is made up of three
components:
Response Status Code ==> 200, 301, 404, 500
(these are the most common ones)
Response Header Fields ==> Date, Server, LastModified, Content-Type
Response Body ==> This is the data that comes
back to the client from the server.
Example 4: http request and http response
HTTP request method is made up of four components:
Request Method ==> Get, Post, Put, Delete (these are
the common ones)
Request URL ==> the URL of the resource
Request Header ==> Accept-Language, AcceptEncoding, User-Agent, Host
Request Body ==> This is the data to be sent to the
HTTP RESPONSE
resource HTTP -RESPONSE- method is made up of three
components:
Response Status Code ==> 200, 301, 404, 500
(these are the most common ones)
Response Header Fields ==> Date, Server, LastModified, Content-Type
Response Body ==> This is the data that comes
back to the client from the server.