Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
13 | |
8 | |
8 | |
7 |
User | Count |
---|---|
17 | |
13 | |
7 | |
6 | |
6 |