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
sugna66
Frequent Visitor

Data Connection search coming back as HTML not JSON

Screen Shot 2019-02-20 at 11.07.38 AM.png

When I make this report search request via chrome I get JSON back and when I make the request in my Power BI data connector I get back HTML. The error I get is "Invalid credential" but I can see the data connector login via the server log. even if I just grab the path from Fiddler and drop it into Chrome I get json back. Why would the Power BI Data Connector query bring back HTML? 

 

here's the query: 

 

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/reports/search?auth=" & hash & "&keyword=EXCEL", [ Headers = DefaultRequestHeaders ]),
       source = Web.Contents(dump, [ Headers = DefaultRequestHeaders ]),
       json = Json.Document(source)
        
    in
        json;
                       


    DefaultRequestHeaders = [
   // #"Content-Type" = "application/json;odata.metadata=minimal",
    #"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 = [
         UsernamePassword = []

    ],

It's supposed to bring back a list of reports that have the keyword "EXCEL" attached. 

 

Any help would be appreciated. 

2 REPLIES 2
sugna66
Frequent Visitor

Figured out that when I pass the API request in chrome or another browser it passes a Cookie as part of the header. In the data connector request that cookie is absent. If I manually add it to the request header it works. But I can't imagine that cookie string is evergreen. What should the Cookie value be in the request header? Or does it just need some/any value? 

Hi @sugna66 

There are some threads you could refer to:

Passing Cookie using Web.Contents in PowerBI Desktop

Working with Web Services in Power Query

 

Best Regards

Maggie

 

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.

Top Solution Authors
Top Kudoed Authors