Forum Discussion
Including the knowbe4 API in data model with BEARER autorization key
- 1 year ago
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.
how do i include an autorization key in powerbi for the api