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.
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
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.