Forum Discussion
Powerbi and intune api connect
Hi Wiatt ,
Based on your description, when attempting to connect to the Microsoft Graphics API to obtain data from a Power BI dashboard, you receive an error message indicating that there are limitations in the way Power Query handles certain types of headers, especially when using authentication methods other than anonymous. You can try using functions with options to bypass the limitations of the "Authorization" header. You can add ManualStatusHandling = {400, 401, 403, 404, 500} to make Power Query manually handle HTTP status codes to allow the use of "authorization" headers even if the connection is not anonymous.
// Get the access token
TokenResponse = Json.Document(Web.Contents(tokenUrl, [
Content = Text.ToBinary(tokenBody),
Headers = [#"Content-Type"="application/x-www-form-urlencoded"],
ManualStatusHandling = {400, 401, 403, 404, 500}
])),
accessToken = TokenResponse[access_token], // Create a function to use the token in the request
GetWithToken = (url as text, token as text) as record =>
let
response = Web.Contents(url, [
Headers=[Authorization="Bearer " & token],
ManualStatusHandling = {400, 401, 403, 404, 500}
])
in
Json.Document(response),
You can also check out the following documentation for more guidance on using the api
Microsoft Graph overview - Microsoft Graph | Microsoft Learn
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi Wiatt ,
Did the above answer solve your problem and if so, you can mark it as an answer so it's easier for other users to find.
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly