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);
pm.environment.set("owner",json.owner.login);
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.
Subscribe our YouTube Channel - / @qascript
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:
• Selenium Webdriver Automation: From Basics...
Jenkins 2.0:
• Jenkins 2.0 & DevOps: Mastering Continuous...
Maven:
• Mastering Maven and Continuous Integration...
Blog Site: https://qascript.com
On this page of the site you can watch the video online Postman Tutorial - Chaining API Requests in Postman with a duration of hours minute second in good quality, which was uploaded by the user QASCRIPT 08 August 2020, share the link with friends and acquaintances, this video has already been watched 5,087 times on youtube and it was liked by 50 viewers. Enjoy your viewing!