API Chaining
Chaining APIs for Multi-Purpose ContextQA
Use API chaining to connect multiple requests in your workflow, making context-aware automation fast and reliable. We'll walk through chaining APIs for a ContextQA test case—passing an access token from one step to another and combining APIs with UI steps for smarter automation.
Enter credentials in the first API test case.
Check the response in the result section to confirm credentials are processed.
Set expected values in validation, such as 200 for success. Create the test step—this gets your access token.
Add a second API by clicking Rest and API method.
Open the options menu with the three dots, then paste in the second API's URL.
Send the request. The response will ask for an access token, but you can’t hard-code it since it expires quickly.
Add Authorization in the header, linking the value to the earlier access token from the first API.
Continue, naming this test result (for example, `result 1`).
Set the expected status code to 200 and create this step.
Execute the test suite. Both steps should complete with a success status.
Review the run results and see how data was retrieved and reused from step to step. The access token and other details from the response in the first API step are fed into the second.
Make your workflow even more powerful by adding a UI step—for example, to navigate to a web page.
Enter the target page's URL.
Create a UI step to enter data in a field, referencing variables like `result 1.body.firstName` from the previous API call.
Assign metadata for your test, such as a username, and provide metadata for the username field.
Click Create to save the step.
Run the test again. The correct locator finds the right field and the test automation inserts the correct first name, demonstrating how data flows from API response to UI action.
Use API chaining to pass data reliably between test steps. Combine API and UI automation for flexible, data-driven workflows. This approach allows you to extract data from APIs and seamlessly push it into UI fields, or take values from UI tests and call APIs with them—unlocking powerful test scenarios.
Last updated