Linux Format

HTTP STATUS CODES

-

According to the HTTP protocol you can define the HTTP method of a request, and RESTful services are no exception. POST is used for creating new resources, GET is used for reading (getting) existing resources and PUT is used for updating existing resources. PUT requests should contain the full and updated version of an existing resource. Additional­ly, the DELETE method is used for deleting existing resources. Finally, PATCH is used for updating existing resources. A PATCH request only contains the modificati­ons to an existing resource.

The most commonly seen HTTP status codes are 200, this means that everything went well and the specified action was executed successful­ly; 201, which means that the desired resource was created; and 202, which means that the request was accepted and is currently being processed (this is usually used when an action takes too much time to complete). Additional­ly, 301 indicates that the requested resource has been moved permanentl­y – the new URI should be part of the response. This is rarely used in RESTful services because usually you use API versioning.

Elsewhere, 400 indicates that there was a bad request and that you should change your initial request before sending it again; 401 means that the client attempted to access a protected request without authorisat­ion; and 403 means that the client doesn’t have the required permission­s for accessing a resource even though the client is property authorised. In UNIX terminolog­y, 403 means that the user doesn’t have the required privileges to perform an action.

Finally, 404 means that the resource wasn’t found; 405 indicates that the client used a method that isn’t permitted by the type of resource; and 500, which means internal server error. Indeed, 500 probably indicates a server failure.

Newspapers in English

Newspapers from Australia