Forum Discussion
Looping Through API with Next Link Parameter
- 1 year ago
use try ... otherwise ... and return an empty list for the latter.
Thanks for your reply, I'm not sure I follow what you mean, could you explain in more detail?
Ah my apologies, I have worked it out - I just needed to add this code:
= List.Generate( () =>
[URL = "https://graph.microsoft.com/v1.0/communications/callRecords",
Result = Json.Document(Web.Contents("https://graph.microsoft.com/v1.0/communications/callRecords", [ Headers = [ Authorization = "Bearer " & access_token ], ExcludedFromCacheKey = {"Authorization"} ] ))],
each [URL] <> null,
each [URL = try [Result][#"@odata.nextLink"] otherwise null,
Result = Json.Document(Web.Contents(URL,[ Headers = [ Authorization = "Bearer " & access_token ], ExcludedFromCacheKey = {"Authorization"} ]))]
)