HTTP methods and status codes in Rest service


The most commonly used HTTP methods in Rest services are as below


1) GET

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.

2) POST

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.

3) PUT

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.

4) DELETE

This method is used to delete the resource specified in the URI.

5) PATCH

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.

1XX

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.

2XX

This is the success status code.

This is used to indicate that the request from the client is received and processed successfully.

3XX

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.

4XX

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.

5XX

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.

About the Author

Karibasappa G C (KB)
Founder of javainsimpleway.com
I love Java and open source technologies and very much passionate about software development.
I like to share my knowledge with others especially on technology 🙂
I have given all the examples as simple as possible to understand for the beginners.
All the code posted on my blog is developed,compiled and tested in my development environment.
If you find any mistakes or bugs, Please drop an email to kb.knowledge.sharing@gmail.com

Connect with me on Facebook for more updates

Share this article on