Article Overview:
This article will cover how you can achieve the following:
guide on the API designed to access the location of files generated/downloaded while executing journeys.
Problem Statement:
Is there an existing/new API to access the location of the files that are generated/downloaded during the execution of the journeys?
Solution:
The files downloaded during the execution of test steps are available in the side effects tab. These can be viewed while reviewing the executed test steps. The variables created during the execution can be used to assert file details and the file content. However, if there is a requirement to fetch the downloaded files via an API for further analysis or actions
The API endpoint api/testsuites/execution can be used to get the execution details including the downloaded file.
We can use this API in Virtuoso or externally, depending upon the use case and requirement to fetch these details. Please follow the steps mentioned below to achieve it in Virtuoso.
Generate a new Bridge token:
- Click on the Profile icon
- Click on “API Tokens”
- Click on the "Create Token" button, choose the token type as "All", provide a suitable name, and then save your selection.
- After creating the token, copy it and securely store it in a notepad file.
- Create a new variable in the Environment tab and toggle the sensitive button. Click "Create Variable" to save the variable.
Retrieve the Job ID from the Execution Link
Once you have your Token, Execute the journey and retrieve the "jobid" from the Execution Link.
Create an API request in the API manager
- Click on the API Managers icon on the left, then click on the New folder option to create a new folder.
- Right-click on the three dots next to the new folder created, then select "New Request" from the list.
- Create a new API request by providing the following details:
- API Name - Execution_API
- API Endpoint - https://api.virtuoso.qa/api/testsuites/execution?envelope=false&jobId={{jobid}}
Note: Make sure to replace "{{jobid}}" with your journey execution job ID. Either using input mapping or hardcoding.
-
- Headers:
- Content-Type - application/json
- httpHeaders - { "myToken":{{TOKEN}}, "fullName": "Your Name" }
Note: Replace "Your Name" with your profile name - Accept - */*
-
Authorization- Bearer Token - $Execution_token
(Note: Add a variable name within the bearer token and in the input mapping, use the same name as the one used to generate the token (i.e., Execution_Token)).
- Save the request and Click on "Send Request" to test the API. Make sure to provide all the values in the input mappings before testing the API.
- Upon sending the request, the API will generate a response along with a success message indicating a "200" status code.
Using the API in the journey and locating the downloaded file
- The API can be called in the journey using the below NLP
Note: Make sure to update input parameters defined in the input mapping in API manager i.e. “TOKEN” and "jobid” in the Step Editor.
Example NLP: API call “Test_JobID”() returning $response
- Upon execution of the journey, a response would be created in the variable $response that contains all the execution details associated with the journey. And the same can be used for asserting any execution related details.
The file URL can be found using the below path from the response variable:
Journey >> Last Execution >> Report >> Checkpoints >> Relevant Checkpoint >> Steps >> Relevant Step >> Side Effects >> Downloaded Files >> URL.
Comments
0 comments
Please sign in to leave a comment.