Hi,
I have a pbix file where I am using a custom created function in Power Query to get coordinates for addresses.
I do that by passing a parameter which stores an APIKey and a variable for the location address.
Everything works fine in Desktop, but when I publish the report I can't schedule a refresh:
From what I read online I need to pass the dynamic part of the url in the function as a relative path.
I tried doing that, but I get another error in Desktop.
Please see below the original code of the function, which works fine in Desktop:
(location as text) =>
let
Source = Json.Document(Web.Contents(
"https://maps.googleapis.com/maps/api/geocode/json?address=" &
location & "&key=" & APIKey)),
#"Converted to Table" = Table.FromRecords({Source}),
#"Expanded results" = Table.ExpandListColumn(#"Converted to Table", "results"),
#"Expanded results1" = Table.ExpandRecordColumn(#"Expanded results", "results", {"formatted_address", "geometry"}, {"formatted_address", "geometry"}),
#"Expanded geometry" = Table.ExpandRecordColumn(#"Expanded results1", "geometry", {"location"}, {"location"}),
#"Expanded location" = Table.ExpandRecordColumn(#"Expanded geometry", "location", {"lat", "lng"}, {"lat", "lng"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded location",{"status"})
in
#"Removed Columns"
Below, please see the update code which uses RelativePath and fires up an error:
(location as text) =>
let
Source = Json.Document(Web.Contents(
"https://maps.googleapis.com/maps/api/geocode/json?address=",
[RelativePath = location & "&key="] & APIKey)),
#"Converted to Table" = Table.FromRecords({Source}),
#"Expanded results" = Table.ExpandListColumn(#"Converted to Table", "results"),
#"Expanded results1" = Table.ExpandRecordColumn(#"Expanded results", "results", {"formatted_address", "geometry"}, {"formatted_address", "geometry"}),
#"Expanded geometry" = Table.ExpandRecordColumn(#"Expanded results1", "geometry", {"location"}, {"location"}),
#"Expanded location" = Table.ExpandRecordColumn(#"Expanded geometry", "location", {"lat", "lng"}, {"lat", "lng"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded location",{"status"})
in
#"Removed Columns"
The error after the update on the M code:
Not sure what am I doing wrong.
Thanks,
Maria