# Making HTTP Requests Through REST API Browser

In this document, we will see how we can make HTTP requests through REST API Browser in Astera.

## **Making a GET Request**

To make a GET request, drag and drop the relevant GET request object from the REST API Browser onto the designer window and pass your required *PetId* into it.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FogKquo2vYk8wXxQJTFL5%2F0.png?alt=media)

In this scenario, we want to get the info for pet with the *PetId* ‘3’. For this, we will select the GET request ‘Find pet by ID’ and pass the relevant *PetId* using a *ConstantValue* object.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FIabptjXRyES7WW86A4uD%2F1.png?alt=media)

To explore the REST Client object for this method, right-click on its header and select *Properties.*

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FmmoAG9YfJ7jr5f4SxeuY%2F2.png?alt=media)

This will open the *REST Client* screen where the connection info of your API is defined.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2F4efr5bkJagnyFk3CIPRM%2F3.png?alt=media)

* *Shared Connection* – shows the name of your REST Connection. You can select any shared REST API Connection you want to use from the drop-down list. The connections for all the APIs that have been imported in the project will be shown here.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FuE9YE7ZizX2PYF7iZwH5%2F4.png?alt=media)

### **REST Request**

* *HTTP Method* – shows the HTTP method of your request
* *Resource* – shows what information you want to get from a specific API. It is a part of the UrI of request sent.
* *Content Type* – shows the type of your content

All the above information is configured according to the request method that you have selected.

Click *Next* to proceed to the *Parameters* screen.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2F0USYuCoDesGLb1536J65%2F5.png?alt=media)

Here, you will see the following options:

* *Name* - it contains the name of the parameter
* *Parameter Location* - it tells which parameter is being used to make the call. The following three parameters are supported by Astera:
  * URL: This is a required parameter.
  * Query: This parameter may or may not be optional and can work as a filter while processing records.
  * Header: This parameter is generally used for authentication purpose.

Click *Next* to proceed to the *Output Layout* screen where you can build the *Response Layout of your API.* There are two ways in which you can generate the output layout:

1. The first one is by providing sample text by clicking on *Generate Layout by providing Sample Text* option.
2. The other way to do that is by running a request by clicking the *Generate Layout by running Request* option.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FI78475Q0JbCOh9KVu4tJ%2F6.png?alt=media)

Click *Next* to proceed to the *Pagination Options* screen.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FHIFazwgL5J4i5DUGJkfr%2F7.png?alt=media)

### **Pagination**

Pagination refers to managing the traffic of records coming from a source. It divides the records into discrete number of pages so that they are comprehensible for a user. Pagination is not supportedby all APIs. For those that do, Astera offers four types of pagination.

### **Offset**

It requires two parameters: a limit and an offset value to be specified by the user. A limit specifies the number of records that you want to specify in one page and an offset simply tells the number of records to be skipped before selecting records.

* *Initial Offset* – the record from which you want to start your pagination
* *Number of Pages –* the number of pages which you want to be processed
* *Limit* - number of records on one page
* *Offset Parameter* - here, you specify the offset parameter of the API that you are working with as specified on the *Parameters* screen
* *Limit Parameter* - here, you specify the limit parameter of the API that you are working with as specified on the *Parameters* screen

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FR2KSkW9ADVxaKEiVrA6G%2F8.png?alt=media)

### **Cursor**

This type of pagination generates a token for the next page of records. You can set a limit to the number of pages you want to process.

* *Cursor Field* – here, the field you want to attach your cursor with is specified.
* *Number of Pages* – here, the number of pages you want to see in your output are specified or you can simply check the option of *Read Till End* if you want to process all the records without any limit.
* *Cursor Parameter* - here, you specify the cursor parameter of the API that you are working with as specified on the *Parameters* screen.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2Fb1YnhcWFuj003MOULwhN%2F9.png?alt=media)

### **Next URL**

It is the same as Cursor pagination, except that it generates a URL for every next page instead of a token.

* *Next URL Field* - here, the field you want to attach your URL with is specified.
* *Number of Pages* - here, the number of pages you want to see in your output are specified or you can simply check the option of ‘Read Till End’ if you want to process all the records without any limit.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FwCN1Z4yBOm9KZ4hLrN3C%2F10.png?alt=media)

### **Page Number**

In this type of pagination, you can specify the number of pages you would like to fetch in one go. It requires two parameters:

* *Start Page Number* - the page number from where you want to start fetching your output or the lower limit
* *End Page Number* - the page number where you want to end
* *Page Number Parameter* - here, you specify the page number parameter of the API that you are working with as specified on the *Parameters* screen

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2Fjn4u1Ulq6HAzWrE5SV04%2F11.png?alt=media)

Click *Next* to proceed to the the *Service Options* screen.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2Fb0gGO1PBtJSf0B2u4S8K%2F12.png?alt=media)

Here you can see the following service options:

* *Request Delay –* the time (in milliseconds) to be delayed before sending a request
* *Retry Count –* the number of retries to be made in case of a failed request
* *Retry Delay –* the time (in milliseconds) to be delayed before making a request again
* *Ignore HTTP Status Codes* checkbox is used to skip the error response for unsuccessful requests
* *Continue on Retry Failure* - this option is used to retry building the connection if it fails
* *Use Parallelism* - this option specifies if you want multiple requests to be run in parallel and the number of those requests can be specified in *Degree of Parallelism* option
* *Include Content as String* - you can check this option if you want to include your content in the output preview
* *Include Response Headers* - you can check this option if you want to include the response headers in you data preview
* *Include Raw Bytes* - you can check this option if you want to include the raw data bytes in your data preview

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FlU9ma8dDMVgXNi5MHKKb%2F13.png?alt=media)

Once you have specified these options, click *OK*.

## **Making a POST Request**

Now, let’s try posting a pet to Petstore. Drag the *Add a new pet to the store* request from the REST API Browser panel and drop it on to the dataflow designer.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FJtxCVfbJy3kQxoWtlzEO%2F14.png?alt=media)

We will pass the required parameters to the POST request object using a Variables object.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2F4Ydv51bq0Z39FPPUpGB4%2F15.png?alt=media)

Now, right-click on the REST API Client (addPet) object and select *Preview Output*.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FoOdyXCufKlZmt4lg4utR%2F16.png?alt=media)

You can see that the *HTTPStatusCode* is 200 which means that the REST API has successfully carried out the action requested by client. Let’s verify it by making a GET request for the same *PetId* which we had posted earlier.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FtgzPudqDgUTV1SntTJWf%2F17.png?alt=media)

You can see that a GET request for *PetId* 1 has returned us the same information which we had posted.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FvyuWaNbuozlfoAJGrRRU%2F18.png?alt=media)

## **Making a DELETE Request**

Now, let’s try making a DELETE request. For that, we will first make a GET request to see if that pet exists on the petstore or not and try to delete that. We will pass *PetId* 5 using a ConstantValue object.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FFqHBi6QN9O7ckOVGaV1r%2F19.png?alt=media)

Right-click on the REST Client (getPetById) object and select *Preview Output*.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2F9VImm2H2lbDdOLDL3KEb%2F20.png?alt=media)

It has fetched the details of the pet with *PetId* 5, and the status shows that the pet is available on Petstore.

To delete this pet record, we will drag and drop the *Deletes a pet* request from the REST API Browser panel on to dataflow designer.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FLZHIg7OLX8LJGtoA1jqr%2Fimage.png?alt=media&#x26;token=06829a9c-050c-42da-8d30-233b44ce7e52" alt=""><figcaption></figcaption></figure>

Pass *PetId* 5 to the DELETE request object using a ConstantValue object.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FXdz583eS9twXT2vWdlmZ%2Fimage.png?alt=media&#x26;token=1357c083-52c0-4335-808f-c6cfde489a24" alt=""><figcaption></figcaption></figure>

Right-click on the REST Client object and select *Preview Output*. You can see that it has returned ‘HTTPStatusCode’ 200 which indicates a successful execution.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FjxaPqejSZaaIo7TxjagD%2Fimage.png?alt=media&#x26;token=f6b52864-5b12-4194-9419-170dbb976066" alt=""><figcaption></figcaption></figure>

Let’s verify it by making a GET request again and check if pet with *PetId* 5 has been deleted.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FuF1xyy064MImhcR8vSgA%2Fimage.png?alt=media&#x26;token=618b3f92-24c6-452c-bcc9-03c0c2c857d0" alt=""><figcaption></figcaption></figure>

Right-click on the REST API Client (getPetById) object and select *Preview Output.*

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FFzx78NWOZo0QhnnGYhhY%2Fimage.png?alt=media&#x26;token=0318505b-f265-4701-8303-8bbed7240138" alt=""><figcaption></figcaption></figure>

You can see that Astera has returned error 404 which means that there is no pet found with *PetId* 5 and the pet record has been successfully deleted from petstore API.

## **Making a PATCH Request**

Let’s make a GET request to see what information is there in the user ID where we want to update something.

To make a GET request, drag and drop the ‘GetUser’ method from the REST API Browser onto the designer window.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FBJqKLrHXidAJdkpTXmTP%2Fimage.png?alt=media&#x26;token=257dd2eb-9eb8-45ae-8e38-a41ef676f23d" alt=""><figcaption></figcaption></figure>

Pass userID ‘89’ to the *userId* under the *Parameters* node in the ‘GetUser’ object using *ConstantValue* transformation.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FypHvfhscHDCXG66DVufH%2Fimage.png?alt=media&#x26;token=6054049b-1f17-4e65-8216-bf100967a370" alt=""><figcaption></figcaption></figure>

Right-click on the header of REST Client (GetUser) object and select *Preview Output*.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FnJ6HUWhn1eA6PPSvITVJ%2Fimage.png?alt=media&#x26;token=939a8deb-4197-43a6-94d8-9007fe4f699c" alt=""><figcaption></figcaption></figure>

Here is what the output looks like:

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FD5CXINJpvFPEczWhePLS%2Fimage.png?alt=media&#x26;token=51799599-8d20-471c-9ffc-a96a607645d9" alt=""><figcaption></figcaption></figure>

Now, drag and drop the ‘PatchUser’ method from the REST API Browser and drop it on to the designer window.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FJVsUxuUYWxdALQTJV6xK%2Fimage.png?alt=media&#x26;token=74f837b3-9614-4034-acad-0f38eafdd1ad" alt=""><figcaption></figcaption></figure>

Pass *userId* ‘89’ and *email* ‘<updatedemail@astera.com>’ using a *Variables* resource object.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FhbqPtNUChOmOqEHX5TKs%2Fimage.png?alt=media&#x26;token=65619b84-3517-4bd1-a61a-8aff3a7031d4" alt=""><figcaption></figcaption></figure>

Right click on the *PatchUser* and select *Preview Output*.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2Fe3iAdwQAsukjejKrqHyf%2Fimage.png?alt=media&#x26;token=3e4bd381-2079-43f4-8df8-0602395e2de2" alt=""><figcaption></figcaption></figure>

You can see that the ‘HTTPStatusCode’ is 200 which means that the REST API has successfully carried out the PATCH request. Let’s verify it by making a GET request for the same *userId* in which we made the changes.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FZRcn6aL2zf04zHHVHJ6m%2Fimage.png?alt=media&#x26;token=f8083166-49bc-497b-a654-619b744e2175" alt=""><figcaption></figcaption></figure>

Right-click on the header of the ‘GetUser’ object and select *Preview Output*.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FA7WgdfvJuuPx6P4FUt00%2Fimage.png?alt=media&#x26;token=65071de4-871d-4aa2-be31-bf1f8e1f2c37" alt=""><figcaption></figcaption></figure>

As you can see, the request has been successfully carried out and the email address has been updated to [***updatedemail@astera.com***](mailto:updatedemail%40hotmail.com).

## **Working with APIs That Require Authentication**

Let’s try making an API request that needs authentication. We’ll be making a GET request object using an Adafruit API.

1. First, import the API by using the relevant import source. In this case, we will import using the JSON/YML URL import source.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FxovrfTA48IGw6mOjdI9Q%2Fimage.png?alt=media&#x26;token=356bde24-64e5-42a1-95e1-29a1697300e2" alt=""><figcaption></figcaption></figure>

You will see that all the APIs present on Adafruit’s URL have been populated in the REST API Browser.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2F7SGfyg2b1h7dfIFe15ss%2Fimage.png?alt=media&#x26;token=963a1d2e-2e41-43ef-943b-70fefcf2c8a1" alt=""><figcaption></figcaption></figure>

2. Now, you need to authenticate Adafruit’s APIs to use them in your dataflow. Without authentication, you will get an error. To authenticate an API, go to the *Project Explorer* and double click on the API’s *.sact* file under the Shared Connection node. In this case, we will double-click on Adafruit’s *.sact* file.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2F0JzhoGWBoxW48AJAZ5VV%2Fimage.png?alt=media&#x26;token=e7a64360-6395-484b-96a0-60aa69010727" alt=""><figcaption></figcaption></figure>

3. Adafruit’s *.sact* file will open on the designer. Now, right click on shared action file’s header and select *Properties*.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FnXJtg9a6yzNHjjOn17Do%2Fimage.png?alt=media&#x26;token=56a9f58d-6eb3-4567-9ffb-5c152f295829" alt=""><figcaption></figcaption></figure>

This will open the REST Connection window where you can configure the settings to authenticate Adafruit’s API.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FxOYgl8zHTeS0OJMCGfAs%2Fimage.png?alt=media&#x26;token=b7cfdca9-2a09-4796-bfe5-79cd415c954d" alt=""><figcaption></figcaption></figure>

**Authentication**

Following authentication types are supported in Astera:

1. No Authentication
2. OAuth 2
3. API Key
4. Basic Authentication
5. Bearer Token

**No Authentication**

With this security type, the user can send requests and receive responses without any kind of authentication from APIs.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FQ04QN1sq3mrq0nVytW18%2Fimage.png?alt=media&#x26;token=0a3e17d1-47b1-4dc6-b701-09e5adb14f56" alt=""><figcaption></figcaption></figure>

**O Auth 2**

In the OAuth 2 authentication, you can select any of the four grant types:

1. Implicit
2. Authorization Code
3. Password
4. Client Credentials

**Implicit**

In this grant type, you only need to provide *Authentication URL* and *Client ID* to request token and authorize.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FSSpXNJQcpeeEZetXJ9hU%2Fimage.png?alt=media&#x26;token=f8865264-94ab-4f2a-9878-2ce7953603cb" alt=""><figcaption></figcaption></figure>

**Authorization Code**

In this grant type, you need to provide *Authentication URL*, *Access Token URL, Client ID*, and *Client Secret* to authorize.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2Flwv5NQvMvexh4pqRN6J3%2Fimage.png?alt=media&#x26;token=b9eeaf09-4463-4040-8c8f-60dea22391d9" alt=""><figcaption></figcaption></figure>

**Password**

In this grant type, you need *Access Token URL, Username, Password*, *Client ID* and *Client Secret* in order to authorize.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FFDtnFifdlB4xCWiuKZoo%2Fimage.png?alt=media&#x26;token=4a922db0-23f8-4b14-b1ed-927d470e41e3" alt=""><figcaption></figcaption></figure>

**Client Credentials**

In this grant type, you need *Access Token URL, Client ID,* and *Client Secret* to authorize.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2Fs980gPgRlsTrBtThhlyI%2Fimage.png?alt=media&#x26;token=da2cd8d6-5e1a-4bf9-8d44-70f5d8e17175" alt=""><figcaption></figcaption></figure>

**API Key**

An API Key is a token that a client provides when it makes an API request. An API key is a secret that only the client and server know. They can be sent in the *Query* string or as a request *Header*.

It requires two parameters for authentication:

1. Key
2. Value

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FZTV8JiL52BhaLIrw0tpN%2Fimage.png?alt=media&#x26;token=1f194ba0-5c5e-471b-9dc8-c9504660d39b" alt=""><figcaption></figcaption></figure>

**Basic Authentication**

Basic Authentication is structured according to the HTTP protocol to provide a username and password when making a REST request. In basic HTTP authentication, a request contains a header field in the form of Authentication: Basic , where credentials are the Base64 encoding of ID and password joined by a single colon “:”.

It requires the following information:

1. Username
2. Password

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2Fk2xIfUWox5yo43wofS52%2Fimage.png?alt=media&#x26;token=4fffad5b-f932-4ba2-9669-c1a08915497a" alt=""><figcaption></figcaption></figure>

**Bearer Token**

Bearer token or token authentication is an HTTP-based authentication. The token is a text string included in the request header. It is generated by the server in response to a login request.

To authorize Bearer token, you need:

1. User Name
2. Password
3. Token URL

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2Fiq3QfizbVvaA1XKNLXZm%2Fimage.png?alt=media&#x26;token=0d8aa963-43cd-4ef0-8ca0-eaaeed891d00" alt=""><figcaption></figcaption></figure>

4. Select the *Security Type* and specify the relevant details.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FSrejo5mSnvl300XfbuAA%2Fimage.png?alt=media&#x26;token=0f9e1ca3-177d-4f3d-94a2-449b46feca0e" alt=""><figcaption></figcaption></figure>

You can see that the *Security Type* has been specified as API Key which means that the Adafruit’s API uses *API Key* as its authentication method.

5. Click *OK.* Now that the API has been authenticated, we can work with the API and make HTTP requests.

To make a GET request, drag and drop the *Get feed by feed key* object from the REST API Browser on to the dataflow designer.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FaHwUTUyGAOzmVSTbgnnj%2Fimage.png?alt=media&#x26;token=cfb01a16-5f15-40c9-b946-a7c86250f27a" alt=""><figcaption></figcaption></figure>

It requires two parameters: *username* and *feed\_key.* We will pass the values to these parameters either by using a source object via mapping it or by specifying the parameter value in the default value column in the properties of the *getFeed* object.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FeowZ5441vFZuSZhzTkQq%2Fimage.png?alt=media&#x26;token=c4764bfa-f7af-464c-aaee-917292989af1" alt=""><figcaption></figcaption></figure>

In this case, we have provided the username through a *ConstantValue* object. Now let’s specify the *feed\_key* in the *Default Value* column in the properties of the getFeed object.

Right click on the *REST Client* object (*getFeed*) and select *Properties*. Go to the *Parameters* screen and specify the *feed\_key* value in the *Default Value* column.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2Ft3neXTiNYotE9rtYwtIu%2Fimage.png?alt=media&#x26;token=e5ef3026-d6f3-44c8-8e7c-35ee4552b69c" alt=""><figcaption></figcaption></figure>

Click *Next* to proceed to the *Output Layout* screen. Here, you can see the Response Layout of your selected method.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2F2N6CyCJfp6sFhMpyZFCj%2Fimage.png?alt=media&#x26;token=4b395a7a-79b9-4edc-a1a4-3a52041c3250" alt=""><figcaption></figcaption></figure>

Click *Next* to proceed to the the *Service Options* screen.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2F3mFzeDpR7Gfd3hpdy1b4%2Fimage.png?alt=media&#x26;token=57857203-48b5-493b-b21b-0a72d1822cd2" alt=""><figcaption></figcaption></figure>

Now, right click on the REST Client (*getFeed*) object and select *Preview Output*.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2F0l6iO0Y5JLTi0mDmqdrE%2Fimage.png?alt=media&#x26;token=21c36e95-2667-464d-8224-9a6b7f0fea55" alt=""><figcaption></figcaption></figure>

You can see that Astera has returned the feed information by providing the required parameters.

This concludes making HTTP requests through REST API Browser in Astera.
