Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
We have a web api data source that lives behind a cloudfare deployment where http 302 redirects are involved.
Using power bi desktop > get data > web [ api ] > enter url details and Authorization header value initial produces an access denied. This was because the services api documentation points to a web api that issues 302 redirects. If we put the redirect url value in things work fine. Problem is that is a brittle solution and instead we'd like to support following the 302 redirects.
We have the following code in place that on "Response = Json.Document(InitialRequest)," line is generating the error "Expression.Error: '302' is not supported by the ManualStatusHandling option.".
Shouldn't 302 be supported and if not any insights on how we properly author web api data source M code to follow a redirect?
let
// initial request to get the redirect url
InitialRequest = Web.Contents("https://my.securityjourney.com/api/v3/public-reporting/users", [ManualStatusHandling={302}]),
//RedirectUrl = Text.FromBinary(InitialRequest[Headers][Location]), // Expression.Error: We cannot apply field access to the type Binary.
Response = Json.Document(InitialRequest), // Expression.Error: '302' is not supported by the ManualStatusHandling option.
RedirectUrl = Response[Headers][Location],
// follow the redirect url to get the actual data
FinalRequest = Web.Contents(RedirectUrl),
Source = Json.Document(FinalRequest),
#"Converted to Table" = Table.FromRecords({Source}),
#"Expanded users" = Table.ExpandListColumn(#"Converted to Table", "users"),
#"Expanded users1" = Table.ExpandRecordColumn(#"Expanded users", "users", {"email", "firstName", "lastName", "totalPoints", "securityChampion", "timeSpent"}, {"users.email", "users.firstName", "users.lastName", "users.totalPoints", "users.securityChampion", "users.timeSpent"}),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded users1",{{"users.email", type text}, {"users.firstName", type text}, {"users.lastName", type text}, {"users.totalPoints", Int64.Type}, {"users.securityChampion", type logical}, {"users.timeSpent", type text}})
in
#"Changed Type"
Hi @myusrn ,
The Web.Contents function in Power Query does have some built-in functionality for dealing with HTTP status codes, including 302 redirects. However, it seems that the ManualStatusHandling option does not support 3021.
To handle 302 redirects, you can try the following approach:
Similar post: Web Connector Redirect - Microsoft Fabric Community
Solved: Power Query Data from Web redirect with cookies (E... - Microsoft Fabric Community
Reference: Handling status codes with Web.Contents for Power Query connectors - Power Query | Microsoft Learn
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for the reply and suggestions. As you can see in the power bi m code i shared above i am doing steps 1 thru 3 that you mention above. The issue is that when i get to step 2 it says that the step 1 use of ". . .ManualStatusHandling={302}])," parameter is not supported. Do you have insights on how else i would "handle the 302 status manually." that is supported?
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
73 | |
71 | |
38 | |
28 | |
26 |
User | Count |
---|---|
99 | |
88 | |
62 | |
42 | |
39 |