Pre-requisite-API
Pre requisite API and Dynamic Variable
Pre requisite API are those API, which are executed before the actual scripts. End user can use the dynamic variables across the script and for the referenced dynamic variable’s pre requisite script will run internally and pre requisite reports will be tagged for the respective scripts.
Contents
Get started with Pre requisite API:
Step-1: Select a project.
Step-2: Under any Functional, Performance or API Process service, click on Project Setup.
Step-3: Under Project Setup, click on Prerequisite API.
Step-4: There will be a list of all the Prerequisite API or if not we can create as required.
Step-5: Click on Add API
Step-6: Your Prerequisite API will require the following Info:
Name – the name of Prerequisite API script
Request URL – a request URL of your script
Timeout – Provide API timeout in ms
URL Encode Enabled – Enable or disable URL Encode
Verbs – the type of API call. GET, POST, PUT, DELETE or PATCH
Step-7: Click a Prerequisite script: Authorization & Certificate tab
For prerequisite APIs, authentication can be done by
Basic Auth - user can add username and password
OAuth 2.0 - user can add Access Token with an option to add access token to Header & Query Param.
If there are certificates in respective project, Authorization & Certificates tab will be enabled and User can add the certificates as mode of authorization for the API’s.
Step-8: Click a Prerequisite script: Headers & Params tab.
On this page, you can add Request Headers, Path parameters and Query parameters. Clicking on the corresponding "Add" button will add a form to the corresponding list.
A Request Header field requires a Key and a Value.
Path and Query parameters require a Parameter Name and a Parameter Value.
Step-9: Click a Prerequisite script: Body tab
When you are doing a POST, PUT, DELETE or PATCH method, the "Body" option will appear. This is where you will add the Body of your Request.
Step-10: Click a Prerequisite script: Data Handlers tab.
Here an user can provide what are the Dynamic Variables that can be generated from API’s Response by selecting “Path Type” as “JsonPath” or “Xpath” and click “Save”.
Use “Path Type” as “JsonPath” when API is of type REST API
Use “Path Type” as “Xpath” when API is of type SOAP API
For JSON path or XPath, can use Path Extractor Tool.
Step-11: Click on Save Button.
Editing a Pre requisite API:
Step 1: Under Project Setup, click on Prerequisite API where there will be a list of all the Prerequisite API.
Step 3: Modify the required changes and click on Save button.
Deleting a Pre requisite API:
Step 3: An user can confirm deletion hitting Delete button.
Running a Pre requisite API:
Step 2: CLick on Run icon.
Step 3: API will get executed and navigated to report listing page.
Viewing a Pre requisite API Report:
Step 1: Under Project Setup, click on Prerequisite API where there will be a list of all the Prerequisite API.
Step 2: CLick on View Report icon.
Step 3: An user will be navigating to result page.
Step 4: Click on View Details
Dynamic Variable
End user can use the dynamic variables across the script and for the referenced dynamic variable’s pre requisite script will run internally and pre requisite reports will be tagged for the respective scripts.
Ability to fetch a dynamic variable
Step 1: Create API and enter all the mandatory fields by clicking on “Add API” button under Variables → Prerequisite API
Step 2: Navigate to “Data Handlers” where you can provide what are the Dynamic Variables that can be generated from API’s Response by selecting “Path Type” as “JsonPath” or “Xpath” and click “Save”.
Use “Path Type” as “JsonPath” when API is of type REST API
Use “Path Type” as “Xpath” when API is of type SOAP API
The above screenshot shows the example of a REST API.
Note:
Variable Names in “Data Handlers” must be unique across pre requisite scripts created.
Avoid giving xpaths for APIs which are having json responses and json paths for APIs having XML responses.
Step-3 : All the created dynamic variable will be listed under Dynamic Variable tab.
Step 4 : To use Dynamic Variables in scripts follow this syntax #VariableName#
Step-5 : Verify dynamic variable on result page.
As we can see in the above snapshot, the dynamic variables have been replaced with the actual values and a successful response is obtained.
As we can see in the above snapshot, the result of Prerequiste API.
Note:
Also please provide valid variable names in data handlers, You can use underscore as the only special character for naming variables.
Valid ones
Invalid ones
Related topics
Last updated