msgraph-sdk-dotnet icon indicating copy to clipboard operation
msgraph-sdk-dotnet copied to clipboard

MsGraph Todo $filter finishes with "Invalid request" error when has "contains(title, '&')" criteria

Open 23W opened this issue 4 months ago • 6 comments

Describe the bug

My application needs to find all Todo Tasks that have & symbol in title field.

So application executes request with filtering criteria contains(title, '&'):

graphClient.Me.Todo.Lists[myListId].Tasks.GetAsync(rc => rc.QueryParameters.Filter = filter)

where filter is string "contains(title, '&')".

MsGraph SDK fires exception "invalidRequest" from server's JSON response:

{
    "error": {
        "code": "invalidRequest",
        "message": "Invalid request",
        "innerError": {
            "code": "RequestBroker--ParseUri",
            "date": "2025-08-12T10:04:15",
            "request-id": "4c70fb4e-18c5-4725-859f-4dfc99e9adcd",
            "client-request-id": "97fa3a5b-08ca-46dd-bdfd-784341a5a308"
        }
    }
}

Expected behavior

MsGrpah SDK should return tasks that are filtered according criteria

How to reproduce

use filter "contains(title, '&')"

SDK Version

5.73.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

23W avatar Aug 12 '25 11:08 23W

Use double encoded ampersand

"contains(title, '%2526')"

MartinM85 avatar Aug 13 '25 06:08 MartinM85

Use double encoded ampersand

"contains(title, '%2526')"

Why? Where it's described in the documentation? What else symbols should be encoded in special way?

23W avatar Aug 14 '25 15:08 23W

@23W https://learn.microsoft.com/en-us/graph/query-parameters?view=graph-rest-1.0&tabs=http#encoding-query-parameters

MartinM85 avatar Aug 15 '25 06:08 MartinM85

@23W https://learn.microsoft.com/en-us/graph/query-parameters?view=graph-rest-1.0&tabs=http#encoding-query-parameters

Do you mean this one? Image This is note about $search param, my question is about $filter.

23W avatar Sep 16 '25 13:09 23W

The note about $search param, but applies also to $filter.

Have you tried double encoded ampersand "contains(title, '%2526')"? Does it work for you.

MartinM85 avatar Sep 16 '25 13:09 MartinM85

The note about $search param, but applies also to $filter.

Have you tried double encoded ampersand "contains(title, '%2526')"? Does it work for you.

Have not tried yet. I decided to do filtering work locally.

23W avatar Sep 16 '25 14:09 23W