Forum Discussion
Dynamic datasource error with relativepath
- 3 years ago
For someone with the same problem, I found a solution myself.
Make a parameter for the whole base URL:
Parameter 1: https://1234.xx.xx.online and add this to the query.
= (offset) =>
let
Source =
Json.Document(
Web.Contents(
Parameter1,
[
RelativePath = "/xxxxxx/xxxx/xxxx?take=1000&skip=" & Number.ToText( offset ),
Headers = [
Authorization = "Token " & (Parameter2)
]
]
)
)
Hi Pi,
Thanks for your reply. Parameter1 is a number and comes immediately after the https://. What you told me to do is exactly what I did right?
= (offset) =>
let
Source =
Json.Document(
Web.Contents(
"https://" & Number.ToText ( Parameter1 ) & ".xx.xx.online",
[
RelativePath = "/xxxxxx/xxxx/xxxx?take=1000&skip=" & Number.ToText( offset ),
Headers = [
Authorization = "Token " & (Parameter2)
]
]
)
)
So if I do it like above, I get the following error in the service: it uses a dynamic datasource so I can't do schedule refresh
- pi_eye3 years ago
Resolver IV
Hi TK12345
According to Chris Webb's blog at https://blog.crossjoin.co.uk/2016/08/23/web-contents-m-functions-and-dataset-refresh-errors-in-power-bi/ the service only looks at the first part of the web.contents function for the dynamic bit.
If you include all dynamic parameters in the relative path, then it will not be detected and should run as usual.
I changed my code to:
let
Source =
Json.Document(
Web.Contents("https://api.coindesk.com/",
[RelativePath="v" & Number.ToText(version_number) &"/bpi/currentprice.json"])
),
bpi = Source[bpi],
USD = bpi[USD]
in
USDHowever, your parameter is in the hostname, so I think we would need to use something other than web.contents.
Pi