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.
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,
Solved! Go to 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.
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
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.