# Creating New API Request

You can create and send an API request using the following options:

* [**Direct API Request**](#sending-a-direct-api-request)
* [**Advanced API Request**](#sending-an-advanced-api-request)

## Sending a Direct API Request

To send a direct API request, perform the following actions:&#x20;

1. On the **Home** page, under **Projects**, select the required **Project**.
2. Select **Design Studio**. In the **Element Repository** page, locate the **Create Folder (+)** icon.&#x20;
3. Select **Create Folder** (**+**) icon and select **Create new folder** to create a new folder for element repository. A new folder is created. &#x20;
4. In the **New Folder** text box, enter the element repository folder name. &#x20;
5. In the newly created folder, select **Ellipsis** (**...**) icon > **Create Repository** > **Webservice** to create the repository.&#x20;

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2FWjg4mXjDDKjd2UvKZStP%2Fimage.png?alt=media&#x26;token=d6c23b59-2507-4a7f-9e5a-aa378686c209" alt=""><figcaption></figcaption></figure>

6. From the **Select** dropdown, choose the required HTTP method:&#x20;
   * **GET**: Used to retrieve information or data from the specified resource.&#x20;
   * **POST**: Used to submit data to the server to create a new resource.&#x20;
   * **HEAD**: Used to request response headers only without the response body.&#x20;
   * **PUT**: Used to update or replace an existing resource with new data.&#x20;
   * **DELETE**: Used to remove the specified resource from the server.&#x20;
   * **PATCH**: Used to apply partial updates or modifications to an existing resource.
7. In the **Enter URL** text box, enter the API endpoint URL.&#x20;
8. In the **Operation** text box, enter the mathematical operation.&#x20;

{% hint style="info" %}
**Note**:&#x20;

* The **Operation** text box is used only when performing API testing for SOAP based services.&#x20;
* As per the requirements, you can specify the value as **Add**, **Subtract**, **Multiply**, or **Divide** in the **Operation** text box.&#x20;
* When you are performing API testing for REST based services, then the **Operation** text box is not applicable.&#x20;
  {% endhint %}

9. Select the **Append** checkbox if you want to overwrite new configuration details onto the existing configuration during a resend or update process.&#x20;

{% hint style="info" %}
**Note**: If existing request details are not overwritten during a resend or update, the previous configuration remains unchanged.&#x20;
{% endhint %}

10. Select the **send** button to execute the API request.

{% hint style="info" %}
After executing the API request, you can go to **Response** tab to view the result. To learn more, [click here](https://docs.avoautomation.com/avo-assure-supported-technologies-for-automation/webservice-automation/viewing-response-details).&#x20;
{% endhint %}

11. Select the **save** button to store the configuration as a Webservice element.&#x20;

{% hint style="info" %}
The saved element can be used while creating API Test Cases.
{% endhint %}

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2FHCkavUykpVOZ7Um7zB0x%2Funknown.png?alt=media&#x26;token=2fc54c26-220b-4d53-8421-8a0a2f49c37d" alt=""><figcaption></figcaption></figure>

## Sending an Advanced API Request

To send an advanced API request, perform the following actions:&#x20;

1. The initial setup for an Advanced API Request follows the same process as Direct API Request (Steps 1–9). After completing those steps, you can configure the additional components such as headers, body, parameters, authorization, and certificate as described below.&#x20;
2. Select the **Header** tab and then enter the API Header details. &#x20;
3. Select the **Body** tab and then enter the API Body details.

{% hint style="info" %}
**Note**: The **Body** tab is only applicable for **POST, PUT** and **PATCH** HTTP requests.&#x20;
{% endhint %}

4. Select the **Params** tab and enter the Query Parameters or Path Parameters as required.&#x20;
5. Select the **Authorization** tab and select the required authorization from the **TYPE** dropdown. Here are the different types of Authorization:

<details>

<summary>No Auth</summary>

To configure **No Auth** authorization, perform the following action:

1. In the **TYPE** dropdown, select the **No Auth** option. 

{% hint style="info" %}
**Note**: When the API does not require authentication, then you can use the No Auth option.
{% endhint %}

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2FqAqutRZnb3ZBGioMYNKI%2Fimage.png?alt=media&#x26;token=7cb24107-993c-46ee-ad12-7eda21b4e88d" alt=""><figcaption></figcaption></figure>

</details>

<details>

<summary>Basic Auth</summary>

To configure **Basic Auth** authorization, perform the following actions: &#x20;

1. In the **TYPE** dropdown, select the **Basic Auth** option. &#x20;
2. In the **Username** text box, enter the **Username**. &#x20;
3. In the **Password** text box, enter the **Password**. &#x20;

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2F4GQu27C92lcpXGqVa5LB%2Funknown.png?alt=media&#x26;token=6a0744ff-9f7a-423d-858d-8e826643f954" alt=""><figcaption></figcaption></figure>

</details>

<details>

<summary>OAuth2.0</summary>

To configure **OAuth2.0** authorization, perform the following actions:

1. In the **TYPE** dropdown, select the **OAuth2.0** option. &#x20;
2. In the **URL** text box, enter the URL. &#x20;
3. In the **Client ID** text box, enter the client id. &#x20;
4. In the **Client Secret** text box, enter the client secret. &#x20;
5. In the **Scope** text box, enter the scope. &#x20;
6. In the **Grant** **Type** text box, enter the grant type. &#x20;
7. Select the **Generate** **Token** button to generate the token. &#x20;

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2Fld1PIVvzppkWcRhKjIj6%2Funknown.png?alt=media&#x26;token=d18aa60a-db39-4ec4-a2fa-66c01ed63175" alt=""><figcaption></figcaption></figure>

</details>

<details>

<summary>Bearer Auth</summary>

To configure **Bearer Auth** authorization, perform the following actions: &#x20;

1. In the **TYPE** dropdown, select the **Bearer Auth** option. &#x20;
2. In the **Bearer** text box, enter the bearer token. 

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2FbPVpy5AVzive5Ej9RCJY%2Funknown.png?alt=media&#x26;token=4d47c4f1-f10f-4895-84db-415c51d0e46c" alt=""><figcaption></figcaption></figure>

</details>

<details>

<summary>Api Key</summary>

To configure **Api Key** authorization, perform the following actions: &#x20;

1. In the **TYPE** dropdown, select the Api Key option. &#x20;
2. In the **Key** text box, enter the key. 
3. In the **Value** text box, enter the value. &#x20;
4. From the **Add to** dropdown, select the required option such as **Header** or **Params**. &#x20;

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2FlpSJxv2SPaR30b1FlvgH%2Funknown.png?alt=media&#x26;token=05402b84-b222-41fa-95ce-8b2018450ae6" alt=""><figcaption></figcaption></figure>

</details>

6. Select the **Certificate** tab and do the following: &#x20;
   * In the **Path** text box, enter the certificate path and certificate key (optional). &#x20;
   * In the **Password** text box, enter the certificate password. &#x20;
   * In the **Auth Username** text box, enter the username. &#x20;
   * In the **AuthPassword** text box, enter the password. &#x20;
   * Select **Submit** button to finalize the API request setup.

{% hint style="info" %}
**Note**: If you want to change or update the configured data, you can select the **Reset** button. 
{% endhint %}

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2F80WTkd92kARibDqJOqug%2Funknown.png?alt=media&#x26;token=359b1b43-1a96-4c32-959d-ab9ae91d2498" alt=""><figcaption></figcaption></figure>

7. After completing all required configurations, select the **send** button to execute the API request.

{% hint style="info" %}
After executing the API request, you can go to **Response** tab to view the result. To learn more, [click here](https://docs.avoautomation.com/avo-assure-supported-technologies-for-automation/webservice-automation/viewing-response-details).&#x20;
{% endhint %}

8. Select the **save** button to store the configuration as a Webservice element.&#x20;

{% hint style="info" %}
The saved element can be used while creating API Test Cases.
{% endhint %}

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2FlsWvZ6b2FB80t4RYbRjU%2Fimage.png?alt=media&#x26;token=30b87466-9808-43bb-a0f4-03b0a456da1c" alt=""><figcaption></figcaption></figure>
