How to get the Failed test cases using Orchestrator API?

Can anyone please guide me on how to get the Failed test cases using Orchestrator API, and If a Test case is failed I need to automatically create a Defect in JIRA tool, Please help me on how to create a defect in JIRA using Orchestrator API?

@BReddy_m

Try to download this activities Jira Software Integration - RPA Component | UiPath Marketplace and use it

Cheers

1 Like

Hi @BReddy_m,

you can try Excellent suggestion by @Venkat4.

In case you if you want it y API follow below.

To get the failed test cases using Orchestrator API, you can use the Test Cases endpoint. Here’s an example of how to use this endpoint to get the failed test cases:

  1. Get the authentication token: To use the Orchestrator API, you will need an authentication token. You can get this token by making a POST request to the /api/Account/Authenticate endpoint with your Orchestrator credentials. Here’s an example using the Http Request activity in UiPath:
Method: POST
Endpoint: https://<your-orchestrator-url>/api/Account/Authenticate
Headers:
    Content-Type: application/json
Body:
    {
        "tenancyName": "<your-tenant-name>",
        "usernameOrEmailAddress": "<your-username>",
        "password": "<your-password>"
    }
Output:
    responseToken (string) = response.Content.ToString
  1. Get the list of test cases: Once you have the authentication token, you can use it to make a GET request to the /testcases endpoint to get a list of all the test cases in Orchestrator. Here’s an example:
Method: GET
Endpoint: https://<your-orchestrator-url>/testcases
Headers:
    Authorization: Bearer <responseToken>
Output:
    responseContent (string) = response.Content.ToString
  1. Filter the failed test cases: The response from the /testcases endpoint will contain a list of all the test cases in Orchestrator. You can filter this list to only include the failed test cases by checking the Status field of each test case. Here’s an example using the Deserialize JSON Array activity in UiPath:
Input: responseContent
Output:
    failedTestCases (JArray) = JArray.FromObject(jsonArray.Where(Function(x) x("Status").ToString.ToLower = "failed").ToList())

To automatically create a defect in JIRA when a test case fails, you can use the JIRA API to create an issue. Here’s an example of how to do this using the Http Request activity in UiPath:

  1. Get the authentication token: To use the JIRA API, you will need an authentication token. You can get this token by following the steps in the JIRA documentation.
  2. Create a JIRA issue: Once you have the authentication token, you can use it to make a POST request to the /rest/api/3/issue endpoint to create a new issue. Here’s an example:
Method: POST
Endpoint: https://<your-jira-url>/rest/api/3/issue
Headers:
    Authorization: Basic <base64-encoded-authentication-token>
    Content-Type: application/json
Body:
    {
        "fields": {
            "project": {
                "key": "<your-project-key>"
            },
            "summary": "Automated test case failed",
            "description": "<description-of-the-failed-test-case>",
            "issuetype": {
                "name": "Bug"
            }
        }
    }
Output:
    responseContent (string) = response.Content.ToString

Note that you will need to replace the <your-jira-url>, <base64-encoded-authentication-token>, <your-project-key>, <description-of-the-failed-test-case> fields with your own values.
3. Parse the response: The response from the JIRA API will contain information about the new issue that was created. You can parse this response to get the issue key, which you can use to reference the issue in JIRA. Here’s