Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hi, i want to know how to use the knowbe4 api key with powerbi, in the most simple way.
i have tried to use m code in advanced edditor,
let
// Define API URL
BaseUrl = "https://eu.api.knowbe4.com",
API_Endpoint = "/v1/users", // Modify this for other API endpoints
API_TOKEN = "Bearer eyJ", // Vervang dit met jouw echte API-token
// Set Authorization headers
Headers = [
#"Authorization" = API_TOKEN,
#"Accept" = "application/json"
],
// Make API request with structured Web.Contents
Bron = Json.Document(Web.Contents(BaseUrl, [
RelativePath = API_Endpoint,
Headers = Headers
]))
in
Bron
and with the web include data but only see these options
i use powerBI desktop, and want to get help please it is taking to much time now
Solved! Go to Solution.
hi @thegreatquestio,
Thank you for using Microsoft Fabric Community Forum.
Here is a solution for including the authorization key in Power BI to access the KnowBe4 API. This solution addresses the issue you are facing with the authorization key, ensuring that Power BI can properly use it for authentication:
Open Power BI Desktop and go to Home → Transform Data → Advanced Editor then replace your M code with the following:
Try this M code:
let
// Define the API base URL and endpoint
BaseUrl = "https://eu.api.knowbe4.com", // Adjust the region if necessary (US or EU)
API_Endpoint = "/v1/users", // Modify to use the correct endpoint if needed
API_TOKEN = "Bearer eyJhbGci..." , // Replace this with your actual API token
// Set the necessary headers for authentication
Headers = [
#"Authorization" = API_TOKEN,
#"Accept" = "application/json"
],
// Make the API request using Web.Contents
Source = Json.Document(Web.Contents(BaseUrl & API_Endpoint, [
Headers = Headers
])),
// If the response is a list, convert it to a table
Data = if List.IsEmpty(Source) then
null
else
Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
Data
Privacy Settings: If Power BI doesn't return data, go to File → Options and Settings → Data Source Settings, find the URL, and set the privacy level to Public or Organizational based on your situation.
Test the Connection: After applying this M code, load the data to see if it fetches the users from the KnowBe4 API successfully.
I hope my suggestions provided valuable insights. If you have any further questions, don’t hesitate to ask in a follow-up message.
If this post helped, please mark it as "Accept as Solution" so others can benefit as well.
Best regards,
Sahasra.
hi @thegreatquestio,
Thank you for using Microsoft Fabric Community Forum.
Here is a solution for including the authorization key in Power BI to access the KnowBe4 API. This solution addresses the issue you are facing with the authorization key, ensuring that Power BI can properly use it for authentication:
Open Power BI Desktop and go to Home → Transform Data → Advanced Editor then replace your M code with the following:
Try this M code:
let
// Define the API base URL and endpoint
BaseUrl = "https://eu.api.knowbe4.com", // Adjust the region if necessary (US or EU)
API_Endpoint = "/v1/users", // Modify to use the correct endpoint if needed
API_TOKEN = "Bearer eyJhbGci..." , // Replace this with your actual API token
// Set the necessary headers for authentication
Headers = [
#"Authorization" = API_TOKEN,
#"Accept" = "application/json"
],
// Make the API request using Web.Contents
Source = Json.Document(Web.Contents(BaseUrl & API_Endpoint, [
Headers = Headers
])),
// If the response is a list, convert it to a table
Data = if List.IsEmpty(Source) then
null
else
Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
Data
Privacy Settings: If Power BI doesn't return data, go to File → Options and Settings → Data Source Settings, find the URL, and set the privacy level to Public or Organizational based on your situation.
Test the Connection: After applying this M code, load the data to see if it fetches the users from the KnowBe4 API successfully.
I hope my suggestions provided valuable insights. If you have any further questions, don’t hesitate to ask in a follow-up message.
If this post helped, please mark it as "Accept as Solution" so others can benefit as well.
Best regards,
Sahasra.
Hi @thegreatquestio,
Since we haven't heard back from you yet, I'd like to confirm if you've successfully resolved this issue or if you need further help?
If you've already resolved the issue, you can mark the helpful reply as a "solution" so others know that the question has been answered and help other people in the community. Thank you again for your cooperation!
If you still have any questions or need more support, please feel free to let us know. We are more than happy to continue to help you.
Hi @thegreatquestio,
As we did not get a response, may I know if the above reply could clarify your issue, or could you please help confirm if we may help you with anything else?
And if the provided information meets your requirements, you can Accept the solution and also give Kudos on that reply. It helps other users who are searching for this same information and find the information.
Your understanding and patience will be appreciated.
Hi @thegreatquestio,
May I ask if you have gotten this issue resolved?
If it is solved, please mark the helpful reply or share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.
Thank you.
how do i include an autorization key in powerbi for the api
Please try the following steps that may help:
1. Test the API request in your browser or Postman to ensure that the token and URL are valid
2. If the returned JSON data is a nested structure, it needs to be expanded into a table, e.g. using Table.FromList(Bron)
3. Configure Power BI data privacy settings, go to File -> Options and Settings -> Data Source Settings, select the URL of the API, and click “Edit Permissions” to set it to “Organization” or “Public. “”
Best Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous
1 i have tryed the postman it returns 200 so it works well and the url is valid.
2 there is nothing wrong with the json powerbi can't accept the api because of the Autorization key
3 tryed it but is doent work
4 i have tryed to als include it with python code
import requests
import pandas as pd
# ✅ Use the correct API URL
API_URL = "https://eu.api.knowbe4.com/v1/users" # Change to US if needed
# ✅ Use the same API token from Postman
API_TOKEN = "eyJhbGci..."
# My api token is 212 tokens long
headers = {
"Authorization": f"Bearer {API_TOKEN}",
"Accept": "application/json",
"User-Agent": "PostmanRuntime/7.29.0", # Simulate Postman
"Cache-Control": "no-cache",
"Postman-Token": "random-value", # Some APIs check for this
"Host": "eu.api.knowbe4.com",
"Connection": "keep-alive"
}
# ✅ Debug: Print headers
print("Sending Headers:", headers)
# ✅ Send API request
response = requests.get(API_URL, headers=headers)
print(len(API_TOKEN))
# ✅ Print response details
print("Response Status Code:", response.status_code)
print("Response Headers:", response.headers)
print("Response Text:", response.text) # Shows exact API error message
but this also does not work