2

I`m working on app using Microsoft Graph to manage groups in AAD. When trying to filter groups that name contains #, using following query:

groups?$filter=(startswith(displayName,'#'))

Exact filter clause of code in C# that produces this error is following:

Filter($"(startswith(displayName,'{name}') or startswith(mail,'{name}'))")

I get following response from Graph:

{
    "error": {
        "code": "BadRequest",
        "message": "Invalid filter clause",
        "innerError": {
            "request-id": "4d80e6a8-326a-4f79-9ea4-0e7924954181",
            "date": "2018-02-06T09:56:01"
        }
    }
}

Documentation does not mention that # is invalid character, moreover- groups are created properly with this character in name.

Can someone confirm that this is a bug in Graph?

I noticed that manual encoding # as %23 seems to fix the issue and filtering works fine.

EDIT - interesting thing - apostrophe ' throws this error even if it`s encoded as %27.

Tomasz
  • 73
  • 7
  • 1
    # is a special character in URLs (bookmark anchor). So you should definitely URL encode it - as you have already discovered. Same goes for non-ASCII characters in the property values. – RasmusW Feb 06 '18 at 11:16
  • @RasmusW this would be obvious for using special characters in web-world. Graph SDK should handle encoding of URL`s at its own. – Tomasz Feb 06 '18 at 14:37
  • 1
    Tomasz, I appreciate your feedback regarding query option encoding. We'll add this to our backlog. – Dmitry Pimenov Feb 06 '18 at 19:28
  • @DmitryPimenov thank you for feedback. Do you possibly have any tips on how to hack this to work with apostrophe search? – Tomasz Feb 07 '18 at 07:51
  • You were correct to encode the `#`. Unfortunately, I'm not sure if there is a work around for the apostrophe. – Dmitry Pimenov Feb 08 '18 at 02:57
  • 1
    See https://stackoverflow.com/a/41516526/5199691 for how to handle apostrophe – MarkHasper Jun 28 '19 at 10:24

0 Answers0