Postman Tutorial - Chaining API Requests in Postman

preview_player
Показать описание
Learn how to chain different API Requests in Postman.

While working with API Requests, every Request may not have all the required information and it requires some additional data from the previous requests. So we need to find a way of passing data from one request to another in Postman.

Since we already created a random value for the repository name, we can use that variable {{repoName}} in all the subsequent API requests wherever required. This is one way of generating data in one Request and using it in other requests.

To demonstrate further, we will use another API Request which will be used for Deleting a Repository in our Github Collection. It accepts two path variables - Repository Name and Owner Name. One of the variable can be replaced with the previously generate random value. For Owner name we will go back to our Post Request which creates a new Repository. Owner name is available in the response body of the request.

We will retrieve the value of the owner name from the response body and assign it to an environment variable. This can later be used in the Delete Repository Request Path Variables. It can be done by adding the below script in the Tests section:

var json = JSON.parse(responseBody);

Path Variables in Delete Request:
owner: {{owner}}
repo: {{repoName}}

Now if run all the requests in our collection in multiple iterations, the complete workflow of creating a repo, getting the repo and deleting it will work seamlessly.

Found this video interesting - Please Like and Share the video.

Have Feedback/Questions - Leave a comment below.

Get access to 100 plus videos on different automation tools. Also never miss out on any new video posted on our channel.

Other Video Playlists on our Channel:
Selenium:
Jenkins 2.0:
Maven:

Рекомендации по теме
Комментарии
Автор

Hi Bijan, just a suggestion. I think a great way of illustrating the power of request chaining is to recreate a 'false' attempt of running a chain of requests using static variables via collection runner. This can then be contrasted with the alternative approach in which requests are 'chained' using dynamic values/variables parsed between each successive request. This scenario should also be ran using the collection runner, in which case we would expect all the requests to pass successfully. The process of chaining requests enables the user to run an entire collection using dynamically generated variables. It is a faster and more effective way running our collection. A great tutorial nonetheless.

jnr
Автор

Sir what is the basic difference between Pre Request Script and Tests in Postman.

sarathkumar
Автор

Hi Bijan,
Could you please share the collection

bharatvarshney
visit shbcf.ru