Search code examples
azuremicrosoft-graph-apimicrosoft-graph-sdks

MS Graph api : using filter with orderby


I'm trying to call graph api with filter and orderby.

https://graph.microsoft.com/v1.0/me/messages?$filter=(contains(subject, 'subject') OR contains(from/emailAddress/name, 'egName')) &$orderby=receivedDateTime

However, I'm getting error like this

{
    "error": {
        "code": "InefficientFilter",
        "message": "The restriction or sort order is too complex for this operation."
    }
}

I really want to call both at a same time. Anyone know the better way? please help me


Solution

  • There are some restrictions when using $orderby

    Properties that are present in $orderby must appear also in $filter and before any properties that aren't.

    GET /v1.0/me/messages?$filter=receivedDateTime ge 1900-01-01 AND (contains(subject, 'subject') OR contains(from/emailAddress/name, 'egName'))&$orderby=receivedDateTime