Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
CarlomV
Helper I
Helper I

Connecting Powerbi to Altegio - API REST

Hi everybody,

I need to connect Power BI Desktop to Altegio platform. Altegio has an API REST 2.0.  https://developer.alteg.io/api  and uses Bearer and User tokens with some procedures and only Bearer with others. I suppose Web connector is preferred to OData, but I don't know where to put GET, POST...Using 3 header parameters, including Authorization only allow Anonymously connection.. I attach an image. If anyone has connected with this platform or has idea why is not working I would appreciate. Thank you a lot !!.

 

PBIWebConnector.jpg

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @CarlomV - To connect Power BI Desktop to Altegio's REST API using the Web connector, follow these steps. It looks like you'll need to set up the connection using GET and POST methods and configure headers for authentication.

steps:

Altegio REST API

 

Open Power BI Desktop:

Go to Home > Get Data > Web.
Configure the URL:

Enter the endpoint URL from Altegio’s API documentation.
Use the appropriate endpoint based on the data you want to retrieve (GET, POST, etc.).
Example URL format: https://api.alteg.io/v1/your_endpoint
Use the Advanced Editor:

Instead of entering the URL directly, click on Advanced to configure headers, method, and parameters.
Set up Request Headers:

In the Advanced Editor, set up the query similar to this:
M
Copy code
let
url = "https://api.alteg.io/v1/your_endpoint", // Replace with the actual endpoint
body = Text.ToBinary("{JSON body if using POST method}"), // Include if using POST; remove if using GET
headers = [
#"Content-Type" = "application/json",
Authorization = "Bearer YOUR_BEARER_TOKEN", // Replace with your bearer token
#"User-Token" = "YOUR_USER_TOKEN" // Replace with your user token if needed
],
response = Web.Contents(url, [
Headers = headers,
Content = body, // Only include for POST method; remove for GET
ManualStatusHandling = {200} // Optionally handle specific status codes
]),
jsonResponse = Json.Document(response)
in
jsonResponse
Replace YOUR_BEARER_TOKEN and YOUR_USER_TOKEN with the actual tokens provided by Altegio.
Note: If you’re using the GET method, remove the Content line.
Specify HTTP Method:

In Power BI, the Web.Contents function defaults to GET. If you need to use POST, include the Content option with Text.ToBinary("{JSON body}") as shown above.
Make sure that you’re using the correct HTTP method (GET or POST) for each API call as specified in the Altegio documentation.
Authentication:

If Power BI prompts you to choose the authentication method, select Anonymous since you’re already passing the tokens directly in the headers.
Check Response and Parse JSON:

Power BI will retrieve the response from the API. Since most API responses are in JSON format, the Json.Document function will parse the JSON data, making it ready to use in Power BI.
Error Handling:

If you encounter errors, double-check the API documentation for the specific endpoint. Some APIs require additional headers or specific formats for the body parameter in POST requests.
You can also add ManualStatusHandling in the Web.Contents function to handle errors like 400 or 401 responses gracefully.

 

hope this steps helps.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

3 REPLIES 3
rajendraongole1
Super User
Super User

Hi @CarlomV - To connect Power BI Desktop to Altegio's REST API using the Web connector, follow these steps. It looks like you'll need to set up the connection using GET and POST methods and configure headers for authentication.

steps:

Altegio REST API

 

Open Power BI Desktop:

Go to Home > Get Data > Web.
Configure the URL:

Enter the endpoint URL from Altegio’s API documentation.
Use the appropriate endpoint based on the data you want to retrieve (GET, POST, etc.).
Example URL format: https://api.alteg.io/v1/your_endpoint
Use the Advanced Editor:

Instead of entering the URL directly, click on Advanced to configure headers, method, and parameters.
Set up Request Headers:

In the Advanced Editor, set up the query similar to this:
M
Copy code
let
url = "https://api.alteg.io/v1/your_endpoint", // Replace with the actual endpoint
body = Text.ToBinary("{JSON body if using POST method}"), // Include if using POST; remove if using GET
headers = [
#"Content-Type" = "application/json",
Authorization = "Bearer YOUR_BEARER_TOKEN", // Replace with your bearer token
#"User-Token" = "YOUR_USER_TOKEN" // Replace with your user token if needed
],
response = Web.Contents(url, [
Headers = headers,
Content = body, // Only include for POST method; remove for GET
ManualStatusHandling = {200} // Optionally handle specific status codes
]),
jsonResponse = Json.Document(response)
in
jsonResponse
Replace YOUR_BEARER_TOKEN and YOUR_USER_TOKEN with the actual tokens provided by Altegio.
Note: If you’re using the GET method, remove the Content line.
Specify HTTP Method:

In Power BI, the Web.Contents function defaults to GET. If you need to use POST, include the Content option with Text.ToBinary("{JSON body}") as shown above.
Make sure that you’re using the correct HTTP method (GET or POST) for each API call as specified in the Altegio documentation.
Authentication:

If Power BI prompts you to choose the authentication method, select Anonymous since you’re already passing the tokens directly in the headers.
Check Response and Parse JSON:

Power BI will retrieve the response from the API. Since most API responses are in JSON format, the Json.Document function will parse the JSON data, making it ready to use in Power BI.
Error Handling:

If you encounter errors, double-check the API documentation for the specific endpoint. Some APIs require additional headers or specific formats for the body parameter in POST requests.
You can also add ManualStatusHandling in the Web.Contents function to handle errors like 400 or 401 responses gracefully.

 

hope this steps helps.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hi again rajendraongole,

I almost got it.  Using M had copied your link for URL, and it lacked "api/" before  "v1".  I have tried with a function requiring just Bearer token and it worked OK, both using M and with Web connector using 3 headers (Accept, Content-Type and Authorization) plus Anonymous connection.

Now I have to discover how to get  User token and try with an API funcion using both tokens.

Hi rajendraongole1,

 

Using M instead of Web connector is not so direct but I have tried an HTTP method GET that only need bearer token.  In URL I have written the tail of API function (not writing GET because is by default) -also tried complete--. It returns Datasource error: Downloaded data is HTML (url wrong or not right credentials).

M query has no syntax errors, I have followed your indications, and even I have also tried adding "Accept" header because Altegio api says its required. No matter, same error message. I have tried querying "Service category", url has the form:  "https://api.alteg.io/v1/service_category/idcompany/servicecategoryid.

Thanks a lot for your help,  I feel I am close but don't get it yet

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.