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 peeps,
I'm trying to connect to an API and go through multiple pages dynamically. I've been watching this video and I'm trying to replicate it in my query but I'm a bit stuck.
https://www.youtube.com/watch?v=05yhwnuCjRw
This is what works:
(nextP as text)=>
let
nextKey = Text.Combine({"""",nextP,""""},""), //adds ""nextKey""
url = "https://URL/runquery?configCode=ds_adminuser",
body = "{
""name"":""User Data"",
""pageSize"":""4"",
""nextKey"":"&nextKey&",
}",
header = [ #"Authorization"="Basic base64auth",
#"Content-Type"= "application/json"],
Source = Json.Document(Web.Contents(
url,
[Headers=header,
Content = Text.ToBinary(body)]
)
),
data = Source[data],
in
data
Now I'm trying to convert nextP into number so I can iterate through it using List.Generate (I haven't gotten that far yet).
When I try to convert it to number it doesn't work and I'm not sure why:
(nextP as number)=>
let
nextKey = Text.Combine({"""",nextP,""""},""), //adds ""nextKey""
url = "https://URL/runquery?configCode=ds_adminuser",
body = "{
""name"":""User Data"",
""pageSize"":""4"",
""nextKey"":"&Number.To.Text(nextKey)&",
}",
header = [ #"Authorization"="Basic base64auth",
#"Content-Type"= "application/json"],
Source = Json.Document(Web.Contents(
url,
[Headers=header,
Content = Text.ToBinary(body)]
)
),
data = Source[data],
in
data
This is what I get:
An error occurred in the ‘’ query. Expression.Error: We cannot convert the value 1 to type Text.
Details:
Value=1
Type=[Type]
Thanks in advance
GT
Solved! Go to Solution.
Please look at just the body part (put body as your "in"). I think you want """ instead of """" in your Text.Combine. Also, you probably need to wrap nextP with Number.ToText(nextP) .
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Please look at just the body part (put body as your "in"). I think you want """ instead of """" in your Text.Combine. Also, you probably need to wrap nextP with Number.ToText(nextP) .
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Thanks Pat,
What worked was the wrapping of nextP with Number.ToText(nextP). I thought I tried that before but it seems I didn't.
Check out the July 2025 Power BI update to learn about new features.