Requirement
Get all the files from the Sharepoint folders recursively (including sub-folders at all levels) that were modified after a specific date, using Graph API.
I have tried different methods, but none worked as expected. I am able to achieve a little progress with the below procedure but got an error- tooManyResources
.
Steps I followed:
Following the below procedure, I am able to get files from Teams Wiki Data
document library (list type), but the same is not working for Shared Documents
it is giving this error code - tooManyResources
.
-
https://graph.microsoft.com/v1.0/sites/<site-id>/lists/
- get all lists of the site.
- There are two document library type lists in the response -
Teams Wiki Data
and Shared Documents
. Noted id
s of both the lists.
-
https://graph.microsoft.com/v1.0/sites/<site_id>/lists/<list_id>/items
- used this without any query parameters and able to see results.
- For the
Shared Documents
library, I can see all the results from sub-folders also. For Teams Wiki Data
few items are returned, I'm not sure why it so, maybe it has only few items in it.
- Again now, added these query parameters to the request.
Query Parameters
{
"Prefer": "HonorNonIndexedQueriesWarningMayFailRandomly",
"$filter": "fields/Modified ge '2022-03-08T08:23:03Z'"
}
- For
Teams Wiki Data
it gives a convincing response. No errors and I can see some documents and folders.
- But for
Shared Documents
, the same request gives following error-
Error Response
{'code': 'notSupported',
'innerError': {'client-request-id': '<>',
'code': 'tooManyResources',
'date': '2023-11-09T16:12:13',
'request-id': '<>'},
'message': 'The request is unprocessable because it uses too many resources'}
- On updating query parameters as below, gives a different error.
{
"Prefer": "HonorNonIndexedQueriesWarningMayFailRandomly",
"$filter": "lastModifiedDateTime ge '2022-03-08T08:23:03Z'"
}
Error
{
"error": {
"code": "BadRequest",
"message": "Invalid filter clause: A binary operator with incompatible types was detected. Found operand types 'Edm.DateTimeOffset' and 'Edm.String' for operator kind 'GreaterThanOrEqual'.",
"innerError": {
"date": "2023-11-09T17:55:52",
"request-id": "<>",
"client-request-id": "<>"
}
}
}
Conclusion
- Please let me know, if any workaround to resolve the above errors -
tooManyResources
and BadRequest - incompatible types
.
- Please suggest any other possible ways to achieve the aforementioned requirement using Graph API (preferred or any better alternative)
References
Thanks in advance.