I have also experiencing same issue. Let me know any workaround for this issue
Microsoft Graph returns 422 error on querying Sharepoint subsites
Hi,
My API tries to query the subsites of a site in a huge Microsoft Sharepoint, but the Graph API returns a 422 "The request is unprocessable because it uses too many resources" error.
The URL I called to achieve this was https://graph.microsoft.com/v1.0/sites/site_id/sites . When using the Graph Explorer, this does return about 8-10 subsites, which are recursively queryable (using their site id in that same URL). This can go about 5 levels deep and each site has a document library with files. In another Sharepoint, my API is able to do this succesfully, because it is way smaller, I assume.
I've also tried using $top and thus limiting the results per response to 1, but that still gave the same error.
Does anyone have an idea how this could be and if there's a workaround for this? Thanks in advance.
Microsoft Security Microsoft Graph
4 answers
Sort by: Most helpful
-
-
RahulB 0 Reputation points
2023-08-08T07:01:13.68+00:00 I am also facing same issue from very long time. Please help on this. I believe so many people are struggling on this issue.
Please help. Thank you.
-
Matthew Watts 25 Reputation points
2023-08-08T07:06:16.2466667+00:00 We had this issue when we attempted to retrieve the site pages for a given site. We fixed it by deleting the pages which were no longer in use and bringing the overall count down, preventing this error from appearing.
-
Ryan Epperson 1 Reputation point
2023-08-08T16:32:55.15+00:00 The way I've addressed this is by taking my query and breaking it up into smaller groups so that I don't get back more than 500 results in a query. Sharing the code that I use below as an example.
$listitems = @() $querythreshold = 500 $listqueries = @() if(($ticketids[-1]-$ticketids[0]) -ge $querythreshold){ if($VerboseLog){ $message = "Query range "+($ticketids[-1]-$ticketids[0])+" is above threshold, breaking query up to gather all results." LogIt -level "WARNING" -message $message -LogFile $LogFile } $startingId = $ticketids[0] $endingId = $ticketids[-1] do{ $lowrange = $startingId; $highrange = $startingId+($querythreshold-1) $listqueries += @('https://graph.microsoft.com/v1.0/sites/'+$siteid+'/lists/'+$listid+'/items?expand=fields(select=TicketID)&$filter=fields/TicketID ge '+"'"+$lowrange+"' AND fields/TicketID le '"+$highrange+"'") $startingId = $startingId+$querythreshold } while ($highrange -lt $endingId) if($VerboseLog){ LogIt -level "VERBOSE" -message "SharePoint will be queried in $($listqueries.count) queries." -LogFile $LogFile } } else { $listqueries = @('https://graph.microsoft.com/v1.0/sites/'+$siteid+'/lists/'+$listid+'/items?expand=fields(select=TicketID)&$filter=fields/TicketID ge '+"'"+$ticketids[0]+"' AND fields/TicketID le '"+$ticketids[-1]+"'") }