'Searching Microsoft Graph api with spaces in the name

I'm using Microsoft Graph to do a search on the displayName for a substring of the name. The $search="displayName:MySearchTerm" format works perfect. But trying to search on the displayName with a space in the term doesn't seem to work as expected.

Using the sandbox application here https://developer.microsoft.com/en-us/graph/graph-explorer?request=groups?$expand=members&method=GET&version=v1.0

If I use the following query format:

https://graph.microsoft.com/v1.0/groups?$search="displayName:Product vi"&$select=displayName&$orderBy=displayName

how can I get it to return only those records that have the term Product vi in the displayName field. It shouldn't return any records in the sandbox because the term Product vi does not appear exactly in any part of the displayName but it currently returns the record "displayName": "Video Production"

I've tried the following without success:

$search="displayName:"Product vi""
$search="displayName:\"Product vi\""
$search="displayName:\\"Product vi\\""
$search="displayName:\\\"Product vi\\\""
$search="displayName:'Product vi'"
$search="displayName:\'Product vi\'"

The $filter format is no good to me as it doesn't search the middle of the displayName for the string.

How do I format the url to get the desired results if it is even possible?



Solution 1:[1]

The trick is to use comma instead of the space in $search clause.

https://graph.microsoft.com/v1.0/groups?$search="displayName:Product,vi"&$select=displayName&$orderBy=displayName

If $search clause contains "displayName:Product,vi" then Graph API will search on displayName for "Product vi"

It can require a special request header:

ConsistencyLevel: eventual

Solution 2:[2]

Try with %22

instead of

%20

good code...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 sergiokml