HTTP methods and status codes in Rest service
The most commonly used HTTP methods in Rest services are as below
This method is used to Get the resource without making any modification to the resource.
GET should only get the resource.
We can call it as Read only method.
This method is used to create a new resource.
Whenever we want to add a new resource, we can post it to the service using POST method.
This method is mostly used for updating the existing resource.
It can also be used to create the Resource if there is no existing resource with passed information.
But It is good option to use POST if we want to create the new resource.
This method is used to delete the resource specified in the URI.
This method is also used to modify the resource but the PATCH request should contain only the required changes rather than a complete resource.
HTTP Status codes
HTTP status code is a 3 digit number which represents the response status from the server.
This is the Informational status code used to indicate that the client request is received and is under process.
This is just like an acknowledgement to the client.
This is the success status code.
This is used to indicate that the request from the client is received and processed successfully.
This is the Redirection success code.
This is used to indicate that further action is required from client side to fulfill the request.
It may be redirected automatically if the second request is GET or HEAD.
This is the Client error status code.
This is used to indicate that there is an error in the client request.
If client is sending invalid data, then it can lead to client error with this status code.
This is the Server Error status code.
This is used to indicate that the server is failed to process the valid request.
This status code indicates that the request is valid but server is not capable of processing it due to some of its internal errors.