# Build-Test-Script

### Build and Execute Test script.

#### Test Script Info

Select the type of API you'll be testing (REST, SOAP, GraphQL).

| Field               | Description                                            |
| ------------------- | ------------------------------------------------------ |
| API type            | Select REST, SOAP or GraphQL.                          |
| Name                | The name of your API script.                           |
| Description         | A description of your script.                          |
| Context Path        | The path to your specific API.                         |
| Protocol            | Defines a set of rules for communication( http/https). |
| Endpoint            | URL where a service or resource can be accessed.       |
| Port Number         | It is network address. For example: 8080.              |
| Verbs               | The type of API call. GET, POST, PUT, DELETE or PATCH. |
| Timeout             | Timeouts are used to avoid waiting APIs response.      |
| URL in code Enabled | Encoding special characters within the URL.            |

![image](/files/xHyUDiNmMsNPKwxUj4jo)

***

#### Authorization:

Authorization in the context of APIs refers to the process of granting or denying access to specific resources, data, or functionalities within an API.

**Type 1: Basic Authentication**

![image](/files/PfdXt6cVw91lTZNi1nWW) **Step 1:** Choose the **Basic Auth** option.

**Step 2:** Provide the following credentials:

* Enter authorized API **Username**.
* Enter your Corresponding **Password**.

**Type 2: OAuth 2.0 Authentication**

![image](/files/zlVYVcXizhN7x0CVr1yC) Step 1 : Select the "OAuth 2.0" option.

Step 2 : Depending on the token retrieval method, do one of the following:

**Option A: Access Token in Headers**

Step-1 : Enter the **Access Token** to be added to headers.

Step-2 : Save the TestScript.

* After saving the access token, it will be added in headers part along with prefix **Bearer**.

**Option B: Access Token in Query Parameters**

Step-1 : Enter the **Access Token** to be added to queryParams.

Step-2 : Save the TestScript.

* After saving the access token, it will be added in query params.

**Select Certificate**

[**Click here to check out option to upload Certificate**](/api-testing/project-setup/certificate.md#adding-certificates-as-mode-of-authorization-in-script)

***

### Headers and Params:

#### Headers

Headers consist of key-value pairs that provide additional information about the request or the client.

* **Key-Value Pair:** Headers convey metadata, authentication tokens, content type, and more to the server.

  ![image](/files/OOhNJZXi7UZ437aPd6fU)

  You can remove headers by clicking on the delete icon.

  ![image](/files/SUDR0QAoj6Cc5x9vM8Bc)

#### Path Parameter:

Path parameters are placeholders in the URL path that are replaced with actual values.

* Provide **Parameter Name, Parameter Value, Parameter Type** details.
* As they allow dynamic and resource-specific interactions, such as accessing specific endpoints or records.

  ![image](/files/Y4SW2Nknl6fiSZ8ph9yC)
* Using Path Parameter in Test Script:

  ![image](/files/LeNmHQPE4AY1ZJzkpSyz)

  **Note**: The name of the path parameter stated in both the Header and Params section must match the path parameter name utilized in the **Info** of your Test Script.
* Path parameters can be removed by clicking on Delete Icon.

  ![image](/files/1GVcSEChigI49OAQHTMF)

#### Query Parameter:

Query parameters are appended to the URL and are used to modify the request or filter responses.

* Provide **Parameter Name, Parameter Value, Parameter Type** details.
* As they enable filtering, sorting, and customizing requests to retrieve specific data.

  ![image](/files/MrkYUAaYlXxoASXxMkRF)
* You can remove Query Parameters by clicking on the delete icon.

  ![image](/files/8utuQu60BhZPoBiyRsOV)

***

### Body

* The payload of data sent in the request's body.
* Typically used for POST, PUT, DELETE, and PATCH requests to send data to the server.
* It include information like JSON objects, XML, or form data that the API endpoint expects.

![image](/files/P5LS5n0cB2o1yTSQxqez)

***

#### Assertions

* Within the realm of API testing, assertions encompass statements or conditions that verify if the real results of API requests and responses align with the anticipated outcomes.
* Various categories of assertions supported within Functional Testing:
  * **Functional Assertions:** Within API testing, Functional Assertions encompass a diverse range of validation techniques. These assertions serve the purpose of confirming the alignment between the anticipated and actual API responses. The supported assertions encompass aspects like Headers, JSON Path, XPATH, body content, and schema validation. For more comprehensive understanding [Click Here](/api-testing/functional-testing/functional-assertions.md)
  * **API to DB assertion:** Within API testing, Functional Testing provides an array of assertions for API-to-DB validation, ensuring that API responses align as expected with corresponding database resources. For more comprehensive understanding [Click Here](/api-testing/functional-testing/api-to-db.md)

### Execute Test Script

Step-1 : Click on **Play icon** to execute test.

![image](/files/HFEli0ROrKn4pieliCed)

Step-2 : Select the Environment name.

![image](/files/1ePjJ0OtR264dmnOfrI7)

Step-3 : Then select desired Environment & click on the **Run** button.

Step-4 : It will be navigated to [Reports Page](/api-testing/functional-testing/report.md).


---

# Agent Instructions: 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://docs.qyrus.com/api-testing/functional-testing/build-test-script.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.
