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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors