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

First Data Connector Rest API

Hello, I am new to the world of Power Query and M... Power BI for that matter. 

 

I am trying to create a data connector to our REST API and running into some difficulty. 

 

When I login authenticating via UsernamePassword I get a table back with my hash token in the second column, fifth row down.

 

The table columns are Name, Value and the row is Name = hash and Value = "sdda009dwdeweassdsdsas" (for example). 

 

I am trying to add that hash back into my table request as follows. I apologize in advance for what you're about to see as this is my first day in power query: 

 

let

Credential = Extension.CurrentCredential(),

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


source = Web.Contents(url & "/api/login/" & CredentialConnectionString[UID] & "/" & CredentialConnectionString[PWD], [ Headers = DefaultRequestHeaders ]),
hashrow = source{5},
hash = hashrow{1},
report = Web.Contents(url & "/api/report/1/output/Reports/Sugna66/test_test?auth=" & [hash], [ Headers = DefaultRequestHeaders ]),
json = Json.Document(report)
in
source;

 

As you can see I don't really understand the table calls yet. Any help with this would be appreciated. 

 

Cheers,

 

 

 

 

1 ACCEPTED SOLUTION

Thanks, 

 

eventually, I figured it out: 

 

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 ]),
json = Json.Document(source)

in
json;

 

It seems like much but it worked for logging in grabbing a report. 

View solution in original post

3 REPLIES 3
sugna66
Frequent Visitor

Bump? Any love here? 

@sugna66 ,

What data format and fields would your REST API return? Power BI Desktop returns all the data the REST API provides.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks, 

 

eventually, I figured it out: 

 

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 ]),
json = Json.Document(source)

in
json;

 

It seems like much but it worked for logging in grabbing a report. 

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