Avinash Gandavarapu
Avinash Gandavarapu

Reputation: 31

Can I use both $search and $filter in a single Microsoft Graph request?

I'm trying to get a list of messages from Outlook through Microsoft Graph by a query with both $search and $filter parameters. I need to get all the messages based on my search criteria and the messages createdDateTime should be greater than the date I sent in the query.

The URL I'm using for the request is:

/v1.0/me/messages?$search=Sharepoint&$filter=createdDateTime gt 2018-01-11T05:00:00Z

But I am getting this error:

{
    "error": {
        "code": "SearchWithFilter",
        "message": "The query parameter '$filter' is not supported with '$search'.",
        "innerError": {
            "request-id": "dabaeb5f-9b89-4370-9e79-c64c4a10ed5f",
            "date": "2018-01-23T08:57:50"
        }
    }
}

Is there a problem with my URL, or is there another way to make the request?

Upvotes: 3

Views: 1809

Answers (3)

Sonali Das
Sonali Das

Reputation: 1026

Please use ?$filter instead of $filter . it should work. Below is the correct request.

/v1.0/me/messages?$search=Sharepoint&?$filter=createdDateTime gt 2018-01-11T05:00:00Z

Upvotes: 0

kehers
kehers

Reputation: 4170

You cannot use $filter or $orderby in a search request.

https://learn.microsoft.com/en-gb/graph/query-parameters#search-parameter

Upvotes: 1

Dmitry Pimenov
Dmitry Pimenov

Reputation: 739

I believe the URL is correct but 'messages' does not currently support $filter in conjunction with $search. One work around here would be to use $search and filter on createdDateTime client-side.

Upvotes: 3

Related Questions