cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Need Cookie in my Rest API Custom data connector - Help please.

// This file contains your Data Connector logic
section SynDNA;

[DataSource.Kind="SynDNA", Publish="SynDNA.Publish"]
shared SynDNA.Feed = Value.ReplaceType(SynDNAImpl, type function (url as Uri.Type) as any);

SynDNAImpl = (url as text) =>

    let
        Credential = Extension.CurrentCredential(),

        CredentialConnectionString = [ UID = Credential[Username], PWD = Credential[Password] ],

       login = Record.ToTable(Json.Document(Web.Contents(url & "/api/login/" & CredentialConnectionString[UID] & "/" & CredentialConnectionString[PWD], [ Headers = DefaultRequestHeaders ]))),
       FilterLogin = Table.SelectRows(login, each _[Name] = "hash" ),
       hash = List.First(Table.Column(FilterLogin, "Value")),
       //source = Web.Contents(url & "/api/report/1/output/Reports/Angus/test_test?auth=" & hash, [ Headers = DefaultRequestHeaders ]),
       source = Web.Contents(url & "/api/reports/search?auth=" & hash & "&keyword=EXCEL", [ Headers = DefaultRequestHeaders ]),
       json = Json.Document(source)
        
        
    in json;



     DefaultRequestHeaders = [
    #"Cookie" = "userkey=1/2321bf021c4a45f23037826cd49fa5d8b619fd6d/8c836beea0263a6f95b59c3e2d6e44ccd741ce50",
    #"Accept" = "application/json;odata.metadata=minimal",  // column name and values only
    #"OData-MaxVersion" = "4.0"                             // we only support v4
];

// Data Source Kind description
SynDNA = [
    Authentication = [
        // Key = [],
         UsernamePassword = []
        // Windows = [],
       // Implicit = [],
       //   Anonymous = []
    ],
    Label = Extension.LoadString("DataSourceLabel")
];

I need a way to generate a cookie to pass to my API. In the code above has a key borrowed from making my request in Chrome. This request works in any browser and curl. But in Visual Studio it doesn't add the Cookie as part of a default request header. If I manually add the cookie from a browser request (like I have above the request works) if not I get a 403 error. Help please.

5 REPLIES 5
Helper III
Helper III

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. 

Helper III
Helper III

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

Helper III
Helper III

Did any of you get through the cookies process? I'm having a hard time working with cookies in power query. There is no information online about it and no doc that can be referred to, making it even more difficult. I see one more post where it was mentioned that the cookies were not allowed due to security reasons in past:

 

https://community.powerbi.com/t5/Developer/How-to-get-set-Cookies-inside-a-visual/m-p/347843

Hello Team

 

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

New Member

Same problem with the onpremise Conector via Logic App Custom Connector. Its not possible to pass the cookie Header Paramter to the api. 

 

#NoCookieParameterPassThroughAtCustomConnector

 

cookie never arrives at the api...

 

2019-08-20_18-50-10.jpg

 

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.