Testsigma provides a robust API to manage and trigger the Executions using RESTful API Calls. These can be used to integrate with any of the third-party CI tools available in the industry such as GitLab, Codeship, CircleCI e.t.c.

 

Start Execution

We can start a Test Plan in Testsigma easily using the following API request and replacing the <execution-id> part with actual Execution ID also known as Test Plan ID.

https://app.testsigma.com/api/v1/execution_results -d "{\"executionId\": \"<execution-id>\"}"

For a particular Test Plan, you can get the complete API request(that uses cURL command) to trigger the execution from the Test Plan page as shown below:


curl -X POST -H "Content-type: application/json" -H "Accept:application/json" -H "Authorization: Bearer eyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxGvug" https://app.testsigma.com/api/v1/execution_results -d "{\"executionId\": \"2090\"}"


And here's the Powershell script(equivalent for the above cURL command):

$url='https://app.testsigma.com/api/v1/execution_results'
$headers=@{'Authorization'='Bearer eyJhbGciOiJIUzUxMiJ9.eyJXXxxxxxxxxxxxxxxxxxxxxxxxxxxXXXXXXXPjuw'}
$body=@{'executionId'='2090'} | ConvertTo-Json

Invoke-RestMethod -Method POST -Headers $headers -ContentType "application/json" -uri $url -Body $body

As you can see, the Test Plan ID in the above cases is '2090'.


The Run Id and some other details are returned in the response for the request if the execution was started successfully.

 

Making the API Call using POSTMAN

Now let us see how to create the same request in PostMan REST API Client with Bearer Authentication:

Note: You need to make sure the request is authenticated. Otherwise, it may return a 401 Unauthorized Error as the response.


In most of the modern clients like Postman, you might have the option to select Bearer Authentication and enter the key in the provided input fields. Simply select the Bearer Token option from the Authorization Tab.



The Run Id along with some other details are returned in the response for the request if the execution was started successfully.