Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
josie_n
Product and Topic Expert
Product and Topic Expert

Part 1 - Getting a Token

Creating a Collection

Before start to setting up the REST calls we are goint to create a Collection. You can create a Collection clicking on the tree dots on the left panel and choosing Create Collection or click on Create Collection link on Usebruno start page.

josie_n_0-1709564124073.png

Then a window will open to add a Name for the Collection. Then click on Browse to chose a folder to save you collection data and click on Create.

josie_n_1-1709564366513.png

Now that a collection is created, we can set up an environment so we can pass the token to our connector call.

Setting Up Environment

Environment can be used to create variables that can be used to set constants or to pass data from a request to another. To do that click on the three dots on you collection name and chose Settings.

josie_n_2-1709564586715.png

Usebruno will open a window with the collection data. Click on the dropdown list that shows No environment top right. Then click on Configure. This same dropdown list will be used later to use your environment data.

josie_n_3-1709564939992.png

You can chose between creating a new environment manually or import environment data. For this example we will Create Environment manually.

josie_n_4-1709565123077.png

The app will ask a name for your environment. For this example I will use the name of the collection. Then click on Create.

josie_n_6-1709565366216.png

On the next screen we will create the variables that will be used. Click on Add Variable.

We will create the following variables:

  • url - Base URL for your Fieldglass environment.  Base URL for test environments: https://<env_code>.fgvms.com/
  • accessToken -  This variable will receive the token value. Here we will leave it blank
  • apiKey - API Key created on Configuration Manager

After adding all variables, click on Save.

josie_n_7-1709566048243.png

The next step is to create a call to obtain the token. Click on the three dots on you collection name and chose New Request.

josie_n_0-1710188083606.png

Next a new window will open to add a Name and the URL. For the URL field we will use the base URL variable we have created and add /api/oauth2/v2.0/token at the end of it. After filling all fields click on Create.

Note: To get a token the method is POST.

josie_n_1-1710188393562.png

Now we will fill the request tabs with information needed to get a token.

  1. Query -  we will add the information below. To do that click on Add Param and then click on the Save button.
NameValue
grant_typeclient_credentials
response_typetoken

josie_n_3-1710189090283.png

 

2. Headers - here we will add the data below. For the APIKey we will use our environment variable. And for the Content-Type just type value below. Click on Add Header to add the values and when you finish click on Save.

 

NameValue
x-api-key{{apiKey}}
Content-typeapplication/json

josie_n_4-1710189313741.png

3. Vars - on this tab we will add the credentials to get the token and read the response from the body. Fill this tab as following:

Pre Request:

NameValue
usernameyour integration user
passwordpassword for your user

Post Request:

NameExpr
accessTokenres.body.access_token

 

josie_n_0-1710193225953.png

4. Auth - this is the last tab. Here we will set the authentication type and reference the creadentials variables created on Vars tab. Click on the dropdown list and select Basic Auth. The Username and Password fields will show. Fill them referecing the variables created. Then click on Save.

josie_n_7-1710191928198.png

After filling all needed tabs it's time to test the request clicking on the arrow beside the Save button.

josie_n_8-1710192057205.png

Then Fieldglass will answer the resquest with the Bearer Token. This token will be saved on the variable we have created on our environment and defined on Vars tab.

josie_n_9-1710192207535.png

 

Next Up

Part 2 – Calling Upload Connectors Using a Token.

Part 3 – Calling Download Connectors Using a Token.