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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

How to add dynamic Headers in an API call

Hi Team


I've been having some tough time with the cookies process with Power BI. I don't see any documentation that can be referred to. Just like how there is documentation for Authorization process(https://docs.microsoft.com/en-us/power-query/handlingauthentication), there should be something to work around Cookies Authentication as well. 

 

I'm trying to make an API call to our Cookies URL and sending the Bearer Token as an Authorization Header in Power BI:

 

let

Cookie = Web.Contents("https://domain/api/cookie", [Headers =[#"Authorization"= "Bearer "&Access_Token("password", "token", "code")[access_token], #"Cookie" = "set-cookie"]])

in
Cookie

 

This is asking me to specify how to connect and when I select "Edit Credentials" and use Anonymous, I get the response just as the domain. Example abc.domain.com. 

 

I've tried replicating the same in Postman by making an API call to the Cookie URL with just the Bearer token as an Authorization header and used Fiddler to monitor the traffic. 

 

Finding:

When the call is made to the Cookies URL the request headers has Cookie added automatically to it. I believe postman is doing this for me and we get a proper response. 

 

Request:

Now if I were to get this working in Power Query, first question is, is this possible and if yes how to go about it. I have tried many different things but haven't had any succcess. 

I've looked at code snippets in different languages from Postman(like Curl, PHP Curl, Swift URLSession, Java etc) and realized that it has one common thing that is adding Cookie as a Header.

How can we do this in Power Query?

 

I've tried using the Cookie as a Header in Power Query and it returns an error:

 

Expression.Error: 'Cookie' isn't a valid Web.Contents option. Valid options are: ApiKeyName, Content, ExcludedFromCacheKey, Headers, IsRetry, ManualStatusHandling, Query, RelativePath, Timeout
 
Simple Curl code snippet from PostMan:
 
curl --location --request GET 'https://domain/api/cookie' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJ............' \
--header 'Cookie: clopeavwb-=xxxxxxxxxxxxxxxx; 
clopeavwb-agw=xxxxxxxxxxxxxxx; 
LSHttp=xxxxxxxxxxxxxxxx; 
currentAssessment=xxxxxxxxxxxxxxxx'
 
This xxxxxxxxxxx actually has values that I have removed here.
1 REPLY 1
Anonymous
Not applicable

Can anyone share some information on this please. I've hit the road block and can't proceed any further until there is some information on how power query works with Cookies. It has become difficult as there is no documentation. 

Appreciate your valuable response. 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.