# HTTP request / API

{% hint style="info" %}
Available on the **PREMIUM** plan and above.
{% endhint %}

If you want to send data or fetch data from a third-party that WotNot does not have a native integration to, you can use the HTTP request action block.

HTTP request allows you to invoke a API endpoint and perform a **GET / POST / PUT** operation.

{% embed url="<https://www.loom.com/share/e3ee11d15a694525831f157686ead7db>" %}
How to use Service Call - Overview
{% endembed %}

## Request

Configure the details for your API request.

### Methods

Choose the method of your API endpoint you want to invoke. WotNot supports:

* GET
* POST
* PUT

### **Endpoint URL**

You must provide the absolute URL, i.e., a URL starting with HTTP or HTTPS.&#x20;

You can also use the variables in the URL by typing '#', as some APIs do not have headers and mention everything in the URL itself.&#x20;

{% code overflow="wrap" %}

```html
https://api.weatherapi.com/v1/current.json?key=e943b863ebed4572b55140350200312&q=#city#

Here in the above URL #city# is the variable that has been used
```

{% endcode %}

### **Headers**&#x20;

Add authentication data to the HTTP request. Commonly used for bearer token based authentication.

{% hint style="info" %}
Make sure you add the **content-type** field to your request.
{% endhint %}

### **Body**

Add the required information you want to send as part of your request.&#x20;

You can send information in two ways:

#### **Raw:**

It is normal JSON format in which the request needs to be passed

<div align="left"><figure><img src="https://360969599-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsrMxU8nO3RjusUiYuXBB%2Fuploads%2FwJiVZlWrx5Jo8cxZmlRd%2FCleanShot%202024-06-20%20at%2019.14.22.png?alt=media&#x26;token=24e2f856-bad1-43b8-ae58-8e0b2389c3b9" alt=""><figcaption></figcaption></figure></div>

#### **Form:**

It allows you to map the fields. You can either provide static value or map the variables

<div align="left"><figure><img src="https://360969599-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsrMxU8nO3RjusUiYuXBB%2Fuploads%2F0LDmXOTMkpI0aogiR23M%2FCleanShot%202024-06-20%20at%2019.15.31.png?alt=media&#x26;token=6bcd41cd-df5b-4a8e-94ad-8134ba6f3eff" alt=""><figcaption></figcaption></figure></div>

## **Response**

When the HTTP request is made, you will receive a response from the API.

You can store the objects received from the API into variables by mapping the fields.

{% code overflow="wrap" %}

```
// Object path for storing the response into variable where list is returned

result.data.list[0].id

// Here the value of the field `id` will be stored in the variable mapped to it.
```

{% endcode %}

{% code overflow="wrap" %}

```
// Object path for storing the response into variable where single value is returned

result.data.id 

// Here the value of the field 'id' will be stored in the variable mapped to it.
```

{% endcode %}

## Testing API request&#x20;

Once you have configured your API request, you can click on the 'Test the API' button and see the response received.

From the response screen, you can directly save the object into a variable by clicking on the + icon.

<figure><img src="https://360969599-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsrMxU8nO3RjusUiYuXBB%2Fuploads%2FjvbOwtMUD6hLrSydzTqc%2FCleanShot%202024-06-20%20at%2019.27.56.png?alt=media&#x26;token=c6de53b6-d950-42ed-9f4e-b52b74905ada" alt=""><figcaption></figcaption></figure>
