Friday, August 12, 2016

API Automation with postman : Understand request and response

As we understand basic UI of Postman now we are going to understand how to deal with sending request and how to read response.

So First and foremost we need any testing API URL to work with request and response.

Good things is that  JSONPlaceholder  provide testing of fake REST API.

You can test with GET , POST , PUT , DELETE using this URL.

So Lets start with API testing.

Root URL : http://jsonplaceholder.typicode.com/

GET Example :

Enter http://jsonplaceholder.typicode.com/posts/1 in request url and select method as GET. Add content type header as json/application. And click on send.  So we are sending request to Get some posts data from client server using postman.





As you can see in above image response of request is display in Body part. Also request is OK so display 200 ok response code.

POST Example :

To pass some data to server we required POST request. So user can pass some data and get desire output in response. To insert or input some data in server database POST , PUT are generally used.


As you can see in above image i am passing json data in raw section. Also request type select as POST and enter http://jsonplaceholder.typicode.com/posts/ url and click on send.
It will send request to server and add post data in database. As you can see response  in Body section and also response code as 201 created.


PUT Example :

To change value of existing data or want to update value of existing posts PUT call is generally use. It is used to update resources of data into server.



As you can see in above image if user want to update some resources value for post id 1 then need to enter roots url with post id. Also select request type as PUT and click on Send.
So It will send PUT request to rest client server and update or change the value for post which id = 1. And also give response in Body with response code.



DELETE Example :

 So for simple want to delete some data from rest client server database you just need to select DELETE and put URL with post id and click on Send. So it will give response code 200 OK means operation is successful and it has delete resource which was requested.



 For more information regarding API code refer this link.


Next blog is for API Automation with postman : Understand environment and collections

No comments:

Post a Comment