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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

how to get cookies from a request to an API?

I am making a request to an endpoint that returns a cookie in the headers, I will use said cookie later in a request that I will pass said cookie as a header. So the steps I need to take are:

1. Make a request to the endpoint that returns the cookie.
2. Make another request to the endpoint where I authenticate with username and password and as header I send the CSRF TOKEN obtained in step 1.
3. I make another request being already authenticated, passing only the Cookie obtained in step 1, said endpoint returns the json that will be the da with which I will work.

What interests me most is being able to obtain the cookie to pass it to the authentication endpoint.
I am currently trying the following to solve the problem in step 1:



     vUrlGetCSRFTOKEN = "",
     TokenBaseUrl = Text.Combine({Uri.Parts(vUrlGetCSRFTOKEN)[Scheme],"://",Uri.Parts(vUrlGetCSRFTOKEN)[Host]}),
     TokenRelativePath = Uri.Parts(vUrlGetCSRFTOKEN)[Path],
     TokenQuery = Uri.Parts(vUrlGetCSRFTOKEN)[Query],

     md = Value.Metadata(Web.Contents(vUrlGetCSRFTOKEN, [
            Headers=[Accept="application/json", Connection="keep-alive",              
                     #"Accept-Encoding"="gzip, deflate"],




But when looking in the headers I don't see the cookie anywhere.


I have previously replicated all this functionality in postman in the following way:




    url: '', //This is Step 1, GET THE COOKIES
    method: 'GET',
        'Accept': 'application/json',  
        'User-Agent':  'PostmanRuntime/7.29.0',
        'Accept-Encoding': 'gzip, deflate, br',
}, function (error, response, { cookies }) {
    console.log("GET COOKIE");
    if (!error) {
        pm.environment.set('xsrf-cookie', cookies.get('XSRF-TOKEN'));
                        url: '',
                        method: 'POST',       
                            'X-XSRF-TOKEN': cookies.get('XSRF-TOKEN'),//STEP 2, AUTHENTICATE ME AND PASS THE COOKIE FROM STEP 1
                            'Accept': 'application/json',  
                            'User-Agent':  'PostmanRuntime/7.29.0',
                            'Accept-Encoding': 'gzip, deflate, br',                    
                        body: {
                            mode: 'formdata',
                            formdata: [{        
                                "key": "email",  
                                "value": "",                               
                                "key": "password",
                    }, async function(err, res){
                        console.log("RESULT TO LOGIN");
                                        url: '', //GET THE DATA TO WORK
                                        method: 'POST',       
                                            'X-XSRF-TOKEN': cookies.get('XSRF-TOKEN'),
                                            'Accept': 'application/json',  
                                            'User-Agent':  'PostmanRuntime/7.29.0',
                                            'Accept-Encoding': 'gzip, deflate, br'                                                  
                                            raw: JSON.stringify(
                                                    page: 1,
                                                    pageSize: 50,
                                                    sort: {},
                                                    type: "page"
                                    }, async function(err, res){
                                        console.log("RESULT PBI RESPONSE");



Thank you !

Frequent Visitor

I am having the same issue! I can't figure out how to get the cookie information from step 1 and then passing it to the following steps.

Hi there,


I did give up on this -- all suggestions did not work.
If you figure this out --> tell me 🙂


Frequent Visitor

Did you solve the issue with getting the cookie from the original request?
I have a similar issue and cannot figure out how to obtain the cookie

Community Support
Community Support

Hi @jgarcia_new ,


Maybe this similar post could help you,

Solved: Saving Cookies from POST Request to Rest API - Microsoft Power BI Community


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.

Thank you for your time, but the link you sent me could help me with step 2 and 3 that I also have to do. But I need to solve step 1, without step 1, I can't get step 2 and step 3. Thank you very much!

Helpful resources


Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors