简体   繁体   中英

Microsoft Graph Mail API with $search filter not working when we check received time is greater

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM