We have discussed, How to create RESTful service in my previous blogs.
Today, We are talking about how to consume RESTful service from the client.
API call using HTTP Methods for RESTful Services
We will cover most uses methods like GET, POST, PUT and DELETE only.
For example purpose, I have created one API solution and will use for following examples.
Postman is using as a REST Client and consumes REST API service.
1. POST
- Using POST request we are going to add new products.
- Open Postman client from chrome browser addon (Note: You can use any REST client for RESTful service)
Check yellow highlighted section from top to bottom.
1. First, select POST from select box
2. Add headers as we know we are talking about RESTful services so JSON format came into pictures.
3. Add Content-Type as "application/json" and Accept as "applicaiton/json".
4. Now time to add your request data on body section. (ref. Images)
2. GET
- Using GET request we are getting existing product data.
1. First, select GET from select box
2. Add URL on URL box ref. image.
3. Add Content-Type as "application/json" and Accept as "applicaiton/json".
3. Click on send button and you will get the result on box section
3. PUT
- Using PUT request we are going to update existing record.
1. First, select PUT from select box
2. Add URL on URL box with product id( ref. image).
3. Add Content-Type as "application/json" and Accept as "applicaiton/json".
4. Product existing data as a JSON format add on body section
3. Click on the send button and you will see record will be updated.
4. DELETE
- Using DELETE request we are going to delete existing record.
1. First, select DELETE from select box
2. Add URL on URL box with product id (ref. image).
3. Add Content-Type as "application/json" and Accept as "applicaiton/json".
3. Click on the send button and delete existing record from the database.
These simple baby steps post help to a newbie on RESTful service.
Give your suggestion for better improvements on the comment section.
Today, We are talking about how to consume RESTful service from the client.
API call using HTTP Methods for RESTful Services
We will cover most uses methods like GET, POST, PUT and DELETE only.
For example purpose, I have created one API solution and will use for following examples.
Postman is using as a REST Client and consumes REST API service.
1. POST
- Using POST request we are going to add new products.
- Open Postman client from chrome browser addon (Note: You can use any REST client for RESTful service)
Check yellow highlighted section from top to bottom.
1. First, select POST from select box
2. Add headers as we know we are talking about RESTful services so JSON format came into pictures.
3. Add Content-Type as "application/json" and Accept as "applicaiton/json".
4. Now time to add your request data on body section. (ref. Images)
2. GET
- Using GET request we are getting existing product data.
1. First, select GET from select box
2. Add URL on URL box ref. image.
3. Add Content-Type as "application/json" and Accept as "applicaiton/json".
3. Click on send button and you will get the result on box section
3. PUT
- Using PUT request we are going to update existing record.
1. First, select PUT from select box
2. Add URL on URL box with product id( ref. image).
3. Add Content-Type as "application/json" and Accept as "applicaiton/json".
4. Product existing data as a JSON format add on body section
3. Click on the send button and you will see record will be updated.
4. DELETE
- Using DELETE request we are going to delete existing record.
1. First, select DELETE from select box
2. Add URL on URL box with product id (ref. image).
3. Add Content-Type as "application/json" and Accept as "applicaiton/json".
3. Click on the send button and delete existing record from the database.
These simple baby steps post help to a newbie on RESTful service.
Give your suggestion for better improvements on the comment section.
0 comments:
Post a Comment