Graph API get all messages between date range all folders

Ward Horsfall 101 Reputation points
2022-06-27T19:03:08.83+00:00

Hi

Is it possible to using the Microsoft graph api to get all messages between a specified date range across all folders.

Could this be done via the $search parameter

If so what is the syntax

Thanks Ward

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,030 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Glen Scales 4,426 Reputation points
    2022-06-28T00:25:15.747+00:00

    see https://learn.microsoft.com/en-us/Exchange/policy-and-compliance/ediscovery/message-properties-and-search-operators?view=exchserver-2019#searchable-properties-in-exchange

    so something like

    {  
        "requests": [  
            {  
                "entityTypes": [  
                    "message"  
                ],  
                "query": {  
                    "queryString": "received>=03/01/2020 AND received<=03/31/2020"  
                }  
            }  
        ]  
    }  
    

    KQL also has a between operation ".." which should still work but they have dropped (or maybe just omitted) it from the doco examples eg

    {  
        "requests": [  
            {  
                "entityTypes": [  
                    "message"  
                ],  
                "query": {  
                    "queryString": "received:05/01/2020..05/31/2020"  
                }  
            }  
        ]  
    }  
    

  2. Mauro Trentini 1 Reputation point
    2022-10-20T23:44:00.89+00:00

    Is it possible to have dateTime filter instead of only date?
    for example https://graph.microsoft.com/v1.0/me/messages?$search="received>=03/01/2020T00:00:00 AND received<=03/31/2020T17:30:00"

    what is the correct syntax to search by date time?


  3. Christian Geiger 0 Reputation points
    2023-04-16T18:36:36.7466667+00:00

    Hallo my goal was to get all the photos stored in my onedrive. I checked the calls made in the browser when access the Photos tap. I suggest the filter can look something like this

    https://api.onedrive.com/v1.0/drives/xxxxxxxxxx/items/root/items?
    $filter=photo ne null
    &orderby=photo/takenDateTime asc
    &select=createdBy,createdDateTime,description,driveId,file,fileSystemInfo,id,image,lastModifiedDateTime,location,name,parentReference,photo,size,shared,tags,video
    &top=1
    &ump=1
    &initialPageDateTaken=1970-01-01T23:00:00.000Z
    &prefer=Migration=EnableRedirect;FailOnMigratedFiles
    &access_token=EwBQA61DB............
    
    0 comments No comments