Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Struggling with the cyclic reference error

I have coded the following function, which recursively calls itself in order to retrieve the full list of users from a REST API:   let GetUserData = (startFrom as number, uCount as number, res...
  • lbendlin's avatar
    lbendlin
    4 years ago

    Your first steps are correct

     

    let
        userCount = Json.Document(Web.Contents("https://storfolloikt.pureservice.com/agent/api/user/count", 
            [
                Headers=[
                    Accept="application/vnd.api+json",
                    #"X-Authorization-Key"= Text.From(#"PUSapikey")
                ]
            ]))[count],
        pages = Number.RoundUp(userCount / 500),

     

    but then you veer off track. Next step is to create a list with all the URLs you need to fetch the data chunks.

     

    since you already know the number of pages you need there is not really a reason to use list.generate any more. A simple 

     

    {1..pages}  

     

    is enough.  Convert that to a table, add your GetUserData function as a custom column, and combine the output.