# API Test Automation

> Studio supports API test automation through the **New Service** wizard. You can import and test API definitions in various API formats, including Swagger, and others. The API test automation capabilities of Studio allow you to build, manage, and run automated tests across different services.

Studio supports API test automation through the **New Service** wizard. You can import and test API definitions in various API formats, including Swagger, and others. The API test automation capabilities of Studio allow you to build, manage, and run automated tests across different services.

After the import, you can use service definitions in Test Automation projects to validate endpoints, responses, and behaviors. You can also publish service libraries as `.nupkg` packages, either locally or to Orchestrator, and reuse them as dependencies in your test workflows.

Studio also supports Postman as an additional option for importing API collections. To import a collection, generate an [API key](https://web.postman.co/settings/me/api-keys.) in your Postman account and use it in the **New Service** wizard. Studio integrates with Newman, the command line runner of Postman, so you can validate collections directly from the command line. For more details on the Postman requirements, visit [Postman collections](https://docs.uipath.com/studio/standalone/2023.10/user-guide/loading-web-services-in-libraries#postman-collections).

## API test example using Postman

The following example uses a data collection defined in Postman, imports it in a Studio library, publishes the library with the collection, installs it in a testing project, and uses testing activities part of the **UiPath.Testing.Activities** pack to verify the data usage.

The test cases are designed for a workflow that automatically applies for loans and retrieves loan data for bank customers.

To check Postman and Newman installation prerequisites read this [page](https://docs.uipath.com/studio/standalone/2023.10/user-guide/loading-web-services-in-libraries#postman-collections).

### Define a Data Collection

In Postman, either define a data collection or import an existing one to your current workspace. We created a data collection for applying for a loan, retrieving, and deleting loan details. When used in a API test project, this collection checks whether the logic of our workflow is correct.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/standalone-docs-image-167217-72ecc09f.webp)

### Import Collections

To import a collection in Studio, create a library project and make use of the **New Service** window. Access to the collection is granted through the Postman API key. Add this key in the **File or Link** field and click **Load**.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/standalone-docs-image-167797-fd8197c5.webp)

Select only the endpoints you would like to load in your project, and add a new **Namespace** if needed.

Check the **Linked collections** box so that a link is used so the newest version of your collection is executed at runtime, instead of a version stored locally. Click **Save** when done.

### Using Data Collections

After the collection is imported in the Studio library, its endpoints are automatically transformed into activities, available in the **Activities** tab, under the namespace that you previously set.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/standalone-docs-image-168237-32543838.webp)

In our example, a separate **Sequence** file was created for each activity generated from the endpoints.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/standalone-docs-image-171688-5c1b2589.webp)

After adding an activity, add the Postman environment (in between quotes `""`) in the **Properties** panel.

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/standalone-docs-image-170447-8c15b789.webp)

Data values defined in the Postman collection are imported as **Arguments**:

![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/standalone-docs-image-170363-4588b138.webp)

Libraries can be published locally or in Orchestrator as a `.nupkg` package.

### Load Library in API Test Project

1. Create a test project in Studio using the **Test Automation** project type.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/standalone-docs-image-171740-a3dfee92.webp)

2. Install the published library as a dependency using the [Manage Packages](https://docs.uipath.com/studio/standalone/2023.10/user-guide/managing-dependencies#managing-dependencies) window.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/standalone-docs-image-169149-993aeadd.webp)

3. Sequence files previously defined in the library are now available in the **Activities** panel under the library's namespace, together with activities generated from the Postman import.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/standalone-docs-image-168549-ec80031b.webp)

4. Use these activities in your API test automation project, combined with activities part of the **UiPath.Testing.Activities** pack. We created a test project to verify the data entered when applying for a loan in our demo application. This small test uses a set of hardcoded variables, visible in the **Properties** panel. This simple test process was used as a smoke test, to check if the application responded correctly. Several such tests can be created in Studio, depending on your automation needs.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/standalone-docs-image-166768-9e7e6a53.webp)

5. To verify several scenarios in one test project, go to the ribbon, New &gt; Data Driven Test Case. Import the data set, as explained [here](https://docs.uipath.com/studio/standalone/2023.10/user-guide/application-testing). Below is an example of such a test case. The values are now stored into arguments, mapped in the activity.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/standalone-docs-image-166468-9f436640.webp)

6. Select **Run file** or **Debug file with data variations** and choose the data to use. This is useful when testing several scenarios with multiple data sets.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/standalone-docs-image-171432-60405a6a.webp)

7. After running the process, the results are visible in the **Output** panel.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/studio/standalone-docs-image-168421-67734da4.webp)
