sharepointsharepoint-api

Sharepoint REST API: Filter GetFolderByServerRelativeUrl by TimeLastModified


I'm trying to filter the call toGetFolderByServerRelativeUrl by using the Sharepoint API based on TimeLastModified or any Modification or Creation date, but I couldn't succeed.

https://mycompany.sharepoint.com/sites/myTeam/_api/web/GetFolderByServerRelativeUrl('/sites/MyTeam/Shared%20Documents/My%20Project')?$expand=Files&$filter=TimeLastModified ge datetime'2023-12-11T00:00:00Z' and TimeLastModified le datetime'2024-01-05T00:00:00Z'

I'm getting all the items in the folder and not the ones created or modified on the requested date.

The documentation seems Deprecated:

https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-folders-and-files-with-rest

https://neganov.blogspot.com/2013/06/filtering-items-by-date-range-using.html

SharePoint REST API Filter for Createdby

https://sharepoint.stackexchange.com/questions/212487/filter-based-on-date-in-rest-query-to-get-item-from-sharepoint-list

https://support.shortpoint.com/support/solutions/articles/1000307202-shortpoint-rest-api-selecting-filtering-sorting-results-in-a-sharepoint-list


Solution

  • Changing the request to the following should resolve your issue:

    https://mycompany.sharepoint.com/sites/myTeam/_api/web/GetFolderByServerRelativeUrl('/sites/MyTeam/Shared%20Documents/My%20Project')/Files?$filter=TimeLastModified ge datetime'2023-12-11T00:00:00Z' and TimeLastModified le datetime'2024-01-05T00:00:00Z'