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.
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.
- v-sgandrathi1 year ago
Community Support
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.- v-sgandrathi1 year ago
Community Support
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.
- v-sgandrathi1 year ago
Community Support
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.