4

I am working with

Microsoft Graph API

I have a requirement to get emails with different filters and with the specified time range. I am using Odata query for the filter, a couple of examples are:

https://graph.microsoft.com/v1.0/users/<Email-id>/<folder-id>/messages?$search="received>2019-07-02T07:16:39.094Z AND received<2019-07-02T07:17:39.095Z AND isRead=false"


https://graph.microsoft.com/v1.0/users/<Email-id>/<folder-id>/messages?$search="received>2019-07-02T07:16:39.094Z AND received<2019-07-02T07:17:39.095Z AND isRead=false AND body:testbody"

Till the morning it was working fine, but now I am facing the 504 Gateway timeout issue

{
"error": {
    "code": "UnknownError",
    "message": "",
    "innerError": {
        "request-id": "f3ecaf3d-e9c2-4b99-8a01-224de9852d57",
        "date": "2019-07-02T11:38:20"
    }
}

After spending some time I observed there is an issue with below filter with the greater sign.

received>2019-07-02T07:16:39.094Z

If I remove this, then this will work fine. It works fine with the less sign as well.

received<2019-07-02T07:17:39.095Z

Any idea team why it stops working?

Pratik
  • 944
  • 4
  • 20
  • One finding here, This is not specific to a field, we got this error when there is no data available. It seems a problem from Microsoft graph API – Pratik Jul 03 '19 at 05:11
  • This seems to be a general issue https://stackoverflow.com/q/56880644/2339622 – Adri Van Houdt Jul 04 '19 at 09:08

1 Answers1

0

The graph api doesn’t like the > in the url. Just replace it with gt.

received gt 2021-01-01...

Complete sample on the odata documentation page.

https://developer.microsoft.com/graph/graph-explorer?request=me/mailFolders/inbox/messages?$filter=ReceivedDateTime+ge+2017-04-01+and+receivedDateTime+lt+2017-05-01&method=GET&version=v1.0

I would just combine both the $search and filter parameter.

See this answer https://stackoverflow.com/a/64134415/639153

Stephan
  • 2,356
  • 16
  • 38
  • The problem with this solution is that it uses $filter instead of $search which handles ge differently. – Jordan May 10 '22 at 14:17