Forum Discussion
Is there a difference between parameters created in the UI and parameters written into a function?
I have a function that lists parameters and then uses them to paginate/offset an api query when invoked. This works fine, but I want to set them up so that I can adjust the parameters without invoking the function and creating a new query/dataset everytime. So, I set the same parameters up using the UI but now my pagination does not work.
I'm wondering if there is some key difference between the two types of parameter, or more likely, what I'm missing that is causing it to break.
Here is the code that works;
let
Source = (maxrecords as number, limitoffset as number, Token, optional query) =>
if query = null or query = ""
then List.Generate(
()=>[Counter = 0],
each [Counter] < maxrecords,
each [Counter = [Counter] + limitoffset],
each Json.Document(Web.Contents("'URL'/api?limit=" & Number.ToText(limitoffset) & "&offset=" & Number.ToText([Counter]), [Headers=[ContentType="application/json", Authorization="Bearer " & Token]])))
else List.Generate(
()=>[Counter = 0],
each [Counter] < maxrecords,
each [Counter = [Counter] + limitoffset],
each Json.Document(Web.Contents("'URL'/api?limit=" & Number.ToText(limitoffset) & "&offset=" & Number.ToText([Counter]) & "&" & query, [Headers=[ContentType="application/json", Authorization="Bearer " & Token]])))
in
SourceAnd this code (with the parameters set through the UI) only returns a single page of data.
let
Source = if query = null or query = ""
then List.Generate(
()=>[Counter = 0],
each [Counter] < maxrecords,
each [Counter = [Counter] + limitoffset],
each Json.Document(Web.Contents("'URL'/api?limit=" & Number.ToText(limitoffset) & "&offset=" & Number.ToText([Counter]), [Headers=[ContentType="application/json", Authorization="Bearer " & Token]])))
else List.Generate(
()=>[Counter = 0],
each [Counter] < maxrecords,
each [Counter = [Counter] + limitoffset],
each Json.Document(Web.Contents("'URL'/api?limit=" & Number.ToText(limitoffset) & "&offset=" & Number.ToText([Counter]) & "&" & query, [Headers=[ContentType="application/json", Authorization="Bearer " & Token]])))
in
SourceI'm sure there's something I'm just not seeing, but I thought it would be worth checking to see if there is some fundamental difference between the two types of parameter that is causing an issue.
Thanks for taking a look!
2 Replies
- v-eachen-msftCommunity Support
Hi Anonymous ,
You could check if the parameter is decimal number in UI. After my tests, both of the methods could finish the cycle. So I think the problem is caused by parameter properties in UI.
- AnonymousNot applicable
v-eachen-msft Thanks for testing it. I've tried them as Any and as Decimal Number and still no luck. My UI doesn't seem to have an option for just plain Number.