web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Automate
Unanswered

Query large data

(0) ShareShare
ReportReport
Posted on by 24
Hi, I am trying to retrieve all groups in our tenant using API: https://graph.microsoft.com/v1.0/groups?$filter=groupTypes/any(c:c eq 'Unified')&$select=displayName,id,visibility. 
 
I configured the workflow using Do-Until and conditional check for nextLinkUri. 
 
However after running for 45 mins, it stopped at record number 395 because the nextLinkUri was empty. But there are around 30k groups in our tenant. 
I removed the default count from do until loop and set the timer to be PT4H. 
 
Any tips on working through pagination for large number of records?
 
At record 395, the URI outputs looks like this, without odata.nextLink
 
 
Looking forward to suggestions. 
Thanks!
Categories:
I have the same question (0)
  • David_MA Profile Picture
    12,966 Super User 2025 Season 2 on at
    I know the exact problem you are having, but I only have one workflow that does this, and I cannot find it at the moment. I used Copilot to help figure this out. What you are doing to check if the next link is provided in the response is correct, but instead of a condition, you need to use a Do until action instead. I asked Copilot trying to remember the correct prompt to get what you need. It generated the response below. Unless I can find my flow (I have about 600 in four environments), I cannot confirm it is accurate.
     
    Copilot Resolution:
     

    To handle pagination with the Microsoft Graph API in Power Automate and ensure your flow doesn’t error out on the last link, you can use the nextLink property to check if there are more pages of data to retrieve. Here’s a step-by-step guide to set up your flow: 

    1. Initialize Variables: 

    • Initialize a variable to store the nextLink URL. 

    • Initialize a variable to store the results. 

    1. HTTP Request to Graph API: 

    • Use the “HTTP” action to make the initial request to the Graph API. 

    1. Apply to Each: 

    • Add an “Apply to each” action to process the results. 

    1. Condition to Check nextLink: 

    • Add a condition to check if the nextLink property exists in the response. 

    • If nextLink exists, set the variable to the nextLink URL. 

    • If nextLink does not exist, end the loop. 

    1. Loop Until No More Pages: 

    • Use a “Do Until” loop to continue making requests until there is no nextLink. 

    Here’s an example of how you can set this up: 

    1. Initialize Variables: 

    • Initialize Variable (nextLink): 

    • Name: nextLink 

    • Type: String 

    • Value: null 

    • Initialize Variable (results): 

    • Name: results 

    • Type: Array 

    • Value: [] 

    1. HTTP Request to Graph API: 

    • HTTP action: 

    • Method: GET 

    • URI: https://graph.microsoft.com/v1.0/your-endpoint 

    • Headers: Add necessary headers (e.g., Authorization) 

    1. Apply to Each: 

    • Apply to each action: 

    • Select the value from the HTTP response. 

    1. Condition to Check nextLink: 

    • Condition action: 

    • Condition: @not(empty(body('HTTP')?['@odata.nextLink'])) 

    • If true: 

    • Set Variable (nextLink): 

    • Name: nextLink 

    • Value: @body('HTTP')?['@odata.nextLink'] 

    • If false: 

    • Set Variable (nextLink): 

    • Name: nextLink 

    • Value: null 

    1. Loop Until No More Pages: 

    • Do Until action: 

    • Condition: @equals(variables('nextLink'), null) 

    • Inside the loop: 

    • HTTP action: 

    • Method: GET 

    • URI: @variables('nextLink') 

    • Headers: Add necessary headers (e.g., Authorization) 

    • Append to Array Variable (results): 

    • Name: results 

    • Value: @body('HTTP')?['value'] 

    • Condition action (same as above) to check for nextLink. 

     

    This setup ensures that your flow will continue to fetch data until there are no more pages, preventing errors on the last link. If you need further assistance or have more questions, feel free to ask!  

  • Verified answer
    KSMB Profile Picture
    24 on at
    HiDavid_MA , 

    Found the solution,  the data was there all along, I was looking at thw wrong array.  Thanks for your inputs. 


    Thanks 
     
  • CZ-12081827-0 Profile Picture
    25 on at
    @David_MA

    This appears to be exactly what I need.  I'm working with a huge excel list and trying, at this point, to just pull ID's that will be filtered by a much smaller SharePoint list. 

    I'm no guru so I'm wondering, do I need to have a SharePoint list prepared to move the data to or does it just stay in an array somewhere? 

    I went through your instructions but I'd a tad stuck on some of the HTTP info.  

    Thanks so much!  

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard