> For the complete documentation index, see [llms.txt](https://qabunch.gitbook.io/qaautomater/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://qabunch.gitbook.io/qaautomater/create-rest-method-for-your-test-suite-ci-cd.md).

# Create Rest method for your test suite( CI/CD)

QAautoMATER allows you to create custom test suites where you can link test scripts. Afterward, you can create RESTful services for these test suites, enabling you to execute the test scripts through REST API calls. These REST services can be seamlessly integrated into any CI/CD pipeline or Windows scheduler for automated testing.

**Create Test suite from Test Suite & CICD page**

{% embed url="<https://youtu.be/jf5ThoetOfE>" %}

**Update Test script order or sequence**

Using drag-and-drop feature on the Test Suite page you can update the test sequence of the test scripts

{% embed url="<https://youtu.be/LqoRmhIIO9s>" %}

**Create your account for test suite**

To run a test suite from REST services, you need a special account. This account holds your expiration time based on its validity. If you are an admin of the account, you can directly create a special account

If your account name is "**spacecraft**," then the user email should be **<spacecraftcicduser@qabunch.com>**. The domain name can be changed, and accounts can be created from the "Add User Profile" section.

Once you log in to the application using the special account, we need to retrieve the access token for this account. We can obtain the access token from the network console.

<figure><img src="/files/bkj986TJIvpPzUGvI3Ei" alt=""><figcaption></figcaption></figure>

**Rest details for Web test suite execution**

**baseurl :** The base URL will be your backend-hosted URL.

**endpoint :**&#x20;

```javascript
cicd/ui/project/:projectName
```

**http method** : Post

Request header&#x20;

```json
{
    "Authorization": "Bearer accessToken",
    "userEmail": "spacecraftcicduser@qabunch.com",
    "userselectedaccount": "Spacecraft",
    "accountlabel": "QaBunch"
}
```

**Body**

```json
{"testSuiteName":"Smoke"}
```

### Curl Command Example

```
curl --location 'https://localhost:3001/cicd/ui/project/Spacecraft' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer token' \
--header 'userEmail: spacecraftcicduser@qabunch.com' \
--header 'accountlabel: QaBunch' \
--header 'userselectedaccount: Spacecraft' \
--data '{
    "testSuiteName": "Smoke"
}'
```

**Please Note**

We can also pass additional data in body section

```json
{ "environment": "Prod", "threadCount": "2", "deviceName": "Chrome", "screenName": "Desktop", "applicationUrl": "https://google.com","recipientEmail","testemail@test.com" }
```

#### Powershell script (for schduler)

We can create PowerShell scripts for executing test scripts using the same POST method to trigger them. These PowerShell scripts can be useful for scheduling tasks on Windows.

```powershell
/# Define your POST request parameters
$body = @{
    testSuiteName = "smoke"
}

# Convert the body to JSON
$jsonBody = $body | ConvertTo-Json

# Define the URL you want to send the request to
$url = "https://localhost:3001/cicd/ui/project/Spacecraft"

# Define your headers
$headers = @{
    "Authorization" = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InNwYWNlY3JhZnRjaWNkdXNlckBxYWJ1bmNoLmNvbSIsImlhdCI6MTcxNDcyNjE1NSwiZXhwIjoxNzM1NTQ4NTU1fQ.uoByMB2dKjCHiujpXBiChQ-t72foyQrpZul-KENpWdM"
    "Content-Type" = "application/json"
    "userEmail"="spacecraftcicduser@qabunch.com"
    "userselectedaccount"="Spacecraft"
}

# Disable certificate validation temporarily
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

try {
    # Send the POST request
    $response = Invoke-RestMethod -Uri $url -Method Post -Body $jsonBody -Headers $headers

    # Output the response
    $response

    # Once you get a response, do something with it
    Write-Host "Response received: $response"
} catch {
    Write-Error "An error occurred while sending the request: $_"
    exit 1  # Exit the script with a non-zero exit code to indicate failure
} finally {
    # Re-enable certificate validation
    [System.Net.ServicePointManager]::ServerCertificateValidationCallback = $null
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://qabunch.gitbook.io/qaautomater/create-rest-method-for-your-test-suite-ci-cd.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
