Forum Discussion
Web.Headers using MS Graph to handle (expected) HTTP-errors seems not possible. Any suggestions?
Unfortunately that does not solve the problem, as ManualStatusHandling is not working from Power Query. So the query halts completely, before I am able to handle the error.
Still hoping there is anybody who nows a workaround for handling HTTP errors from Power Query.
- ams13 years ago
Responsive Resident
Me again with a clarification - @others please correct me/step-in anytime.
NOT all HTTP errors "halt" the query:
- 401 (and 403) will halt the query
- 405 (etc.) will NOT halt the query
Example of 405 NOT halting the query (I tested below on a local webserver that returned 405 on purpose):
let WebContentsWrapper = (url as text, responseFn as function) => let response = Web.Contents(url), ret = try responseFn(response) in ret, wrappedResponse = WebContentsWrapper("http://127.0.0.1:5000/test", Json.Document), usageExample = if wrappedResponse[HasError] = true then "BOOM" else wrappedResponse[Value] in usageExampleThe above query did NOT halt, but returned as expected = BOOM:
And you CAN extract the error from the wrappedResponse record, if you want:
This could be a partial solution for handling NON 401&403 errors.
P.S.: If I would need to save my professional life by handling 401&403 errors in PowerBI 1) I'd implement a custom connector OR 2) I would use a simple "proxy server" hosted somewhere (internally or maybe pipedream.com etc.) that would always return 200 (so that the query doesn't halt) and a json record with actual HTTP error.
Specifically for MS Graph, I see there is also an integration https://pipedream.com/apps/microsoft-graph-api (haven't used it).
Please mark this as answer if it helped.