Share via

Not able to use the function startswith in graph API even with Advanced query parameters

Gurukrishna 20 Reputation points
2024-05-08T17:44:01.3333333+00:00

Need to filter only a few directory roles from a list of 50+ based on displayName. Is there a way to achieve this? As I am unable to use multiple one filter condition at once in the URI

Working -

https://graph.microsoft.com/v1.0/directoryRoles?$filter=displayName eq 'xxxx' Not working -

  1. https://graph.microsoft.com/v1.0/directoryRoles?$filter=displayName eq 'xxxx' and displayName eq 'yyyy'
  2. https://graph.microsoft.com/v1.0/directoryRoles?$filter=displayName eq 'xxxx' and $filter=displayName eq 'yyyy'

Tried using advanced query params, but it seems that those are not supported with directoryRoles resource.

Microsoft Security | Microsoft Entra | Microsoft Entra ID

Answer accepted by question author

  1. Vasil Michev 126.2K Reputation points MVP Volunteer Moderator
    2024-05-09T07:26:16.3466667+00:00

    As mentioned in the documentation, this method only supports filtering via the eq operator, so you cannot use startsWith. In effect, you can only use $filter to match the full name of the role:

    GET https://graph.microsoft.com/beta/directoryRoles?$filter=displayName eq 'Global Reader'
    

    Was this answer helpful?

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.