Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Anonymous
Not applicable

Passing Cookies Between HTTPS requests in Power Query

Hello everyone!

 

I am trying to use my credentials to log in a url and then use the same cookies to fetch the data from another related url. I keep getting the below error message that I don't know how to avoid in the 'Reponse' step. I believe is related to the type of Session being passed to Web.Contents(). 
Expression.Error: We cannot convert a value of type Binary to type Text.
Details:
Value=[Binary]
Type=[Type]

This is my piece of code. I'd very much appreciate any help on getting it right: 

let
LoginUrl = "https://example.com/auth/login",
SecureUrl = "https://example.com/status/",
Payload = [ username = "myusername", password = "strongpass" ],

 

// Create a new session and log in
Session = Web.Contents(LoginUrl, [
Headers = [#"Content-Type" = "application/x-www-form-urlencoded"],
Content = Text.ToBinary(Uri.BuildQueryString(Payload)),
ManualStatusHandling={400,401,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,422,423,424,425,426,427,428,429,431,451,500,501,502,503,504,505,506,507,508,509,510,511}
]),

 

// Get the secure page using the authenticated session
    Response = Web.Contents(SecureUrl, [Headers=[Cookie=Text.Combine(Binary.ToText(Web.Contents(Session, [RelativePath=""])), "; ")]]),
    Content = Text.FromBinary(Response)
in
    Content

Thank you very much in advance!

Javier

 

1 REPLY 1
lbendlin
Super User
Super User

Rather ambitious.  Note that you can simplify lists via ..

 

{400..431,451,500..511}

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.