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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AfsarP1
Helper IV
Helper IV

How to use "set-cookies"

Hello, 

 

Could someone help me understand how to use "set-cookies" in power query. I've been trying this from a long time but do not have any success. I do not see any documentation that could guide me. I've looked at pretty much all the mentions of cookies in the community and none of it helped. 

 

Here is my code:

 

let

request = Web.Contents("https://domain/api/cookie", [Headers=[#"Authorization"="Bearer "&Access_Token("password","token","code")[access_token]]),// Only this gets me the response as abc.domain.com

 

//response = Json.FromValue(request),
//converttojson = Json.Document(response)

 

body = Json.Document(request),
result = if (Record.HasFields(body, {"error", "error_description"})) then
error Error.Record(body[error], body[error_description], body)
else
body
in
result

 

I'm not sure how to use "set-cookies" in the above code as the way it is being used in the below code:

 

---> var cookie = "";

---> var headersForCookie = {
"Host": "abc.domain.com",
"Authorization": "Bearer "+ token
}

request({
"url": "/api/cookie",
"method": "GET",
"headers": headersForCookie
})

in = (err, res, body){
print of// this is a very important step of verification: JSON.docume(res.headers["set-cookie"])}
cookie = res.headers["set-cookie"];

 

I would really appreciate some help on this. 

7 REPLIES 7
AfsarP1
Helper IV
Helper IV

Hello Team

 

I'm still chasing for the information on cookies. I would appreciate any response.

AfsarP1
Helper IV
Helper IV

Its been quite some time and I'm still trying to get information on this. I know we would go out of vacation soon or some would already be on vacation. I would appreciate any inputs before we all head out to our vacation. 

 

Wishing you all happy holidays. 

AfsarP1
Helper IV
Helper IV

@dm-p Thank you for the response. Unfortunately, I don't have a pro account to submit a ticket and from our organisation it might not be possible to get a pro account. Hence, I've been running back and forth in the community here and other places on the internet. 

 

I've looked at the references you have shared and unfortunately, they haven't helped. However, I appreciate your response. 


AfsarP1
Helper IV
Helper IV

Does anyone have any inputs on this. I would appreciate any response. 

Hi @AfsarP1,

From the looks of things, you've mined all existing community content and come up with no further solutions. I suspect that if someone would have figured this out within the community, it would have been shared and searchable in some capacity, as it would be pretty valuable for a lot of people. I would say that if Chris Webb doesn't have a post about it then it's probably not a thing (here's his power query post archive if you want to take a look).

There is some support for authorisation/session handling in custom connectors, but I believe that this is currently all that's possible at present. I don't do any work in this area so can't advise further but there might be something in that documentation that might be able to help you, if you haven't tried it already.

If you're at your limit with the community resources, have you tried opening a support ticket with Microsoft to get an official answer? If you have a pro subscription, support is free.

I personally haven't got this to work in Power Query. In my case, I ended up writing an Azure Function to abstract the logic to a C# endpoint, which would handle this part and return the results to Power Query, effectively wrapping the web API and making it a simple HTTP request for Power Query. The function cost nothing to host and run as the workload could be handled under the consumption plan, and maybe a few hours of my time to write the code. If you're familiar with C#, JS/TS, Python, PHP, Java or PowerShell then these can be a cheap, quick and secure way to manage these kinds of issues, if you haven't considered them.

Good luck,

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




AfsarP1
Helper IV
Helper IV

@Team I've explored everything there is on the internet about cookies using power queries. There is very limited or no information. There have been a very few posts in the past about cookies asking different questions. Looks like a handful of connector might have tried using cookies so far but there is no concrete information online. Could someone from the Microsoft Team, let me know if there is a way to use cookies in Power Query. 

If someone from the community has done it, I would appreciate your inputs.  

AfsarP1
Helper IV
Helper IV

Any help on this would be appreciated. I don't seem to have any alternative to understand this than reaching out to the community. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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