Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi Power Bi community,
I am a little bit new in Power Bi, and I am facing an issue when I refresh the data source on the service page.
The code is the following:
/*
let
Source = Json.Document(Web.Contents("api.xxxxcom", [RelativePath="/xxxxx/authentication/login",Query=[username=API_Username, password=API_Password], Headers=[#"Ocp-Apim-Subscription-Key"=API_SubscriptionKey]]))[userCode],
EarliermachineItemNumber = Table.SelectColumns(API_GetMachineMetadata, "machineItemNumber"),
#"Changed Type1" = Table.TransformColumnTypes(EarliermachineItemNumber,{{"machineItemNumber", type text}}),
Token = Table.AddColumn(#"Changed Type1", "Request", (earlier) => Json.Document(Web.Contents("//api.xxxxcom", [RelativePath="/xxxx/v2/machines/" & Text.From(earlier[machine]) & "/info", Headers=[#"X-Auth-Token"=Source, #"Ocp-Apim-Subscription-Key"=API_SubscriptionKey]]))),
#"Expanded Request" = Table.ExpandRecordColumn(Token, "Request", {"machineItemNumber", "machineId", "machineName", "machineCompany", "machineSite", "machineType", "machineModel", "machineLatitude", "machineLongitude", "machineTimeZone", "machineLastContact", "machineLastData"}, {"machineItemNumber.1", "machineId", "machineName", "machineCompany", "machineSite", "machineType", "machineModel", "machineLatitude", "machineLongitude", "machineTimeZone", "machineLastContact", "machineLastData"}),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Request",{{"machineLastContact", type datetime}, {"machineLastData", type datetime}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"machineItemNumber.1"}),
#"Sorted Rows" = Table.Sort(#"Removed Columns",{{"machineLastContact", Order.Descending}}),
#"Merged Queries" = Table.NestedJoin(#"Sorted Rows", {"machineItemNumber"}, SQL_MachineComments, {"machine_itemnumber"}, "SQL_MachineComments", JoinKind.LeftOuter),
#"Expanded SQL_MachineComments" = Table.ExpandTableColumn(#"Merged Queries", "SQL_MachineComments", {"updated", "comments"}, {"updated", "comments"}),
#"Reordered Columns" = Table.ReorderColumns(#"Expanded SQL_MachineComments",{"machineItemNumber", "machineId", "machineName", "machineCompany", "machineSite", "machineType", "machineModel", "machineLatitude", "machineLongitude", "machineTimeZone", "machineLastContact", "machineLastData", "comments", "updated"})
in
#"Reordered Columns"
*/
I have uncertainty in the following line:
Token = Table.AddColumn(#"Changed Type1", "Request", (earlier) => Json.Document(Web.Contents("api.xxx.com", [RelativePath="/xxx/v2/xxxx/" & Text.From(earlier[machineItemNumber]) & "/info", Headers=[#"X-Auth-Token"=Source, #"Ocp-Apim-Subscription-Key"=API_SubscriptionKey]]))), |
Thanks for all the help
🙂
Hi @LeninD
Does the query work in power bi desktop?
If it is ok, does it prompt with a window to let you enter credential?
Is the authentication written in web url directly?
Best Regards
Maggie