How to retrieve Sharepoint site that contains special characters or numbers using Graph .NET SDK
I'm using the latest Microsoft Graph .NET SDK. Using delegated permissions, I try to retrieve a SharePoint site by it's display name. Let's say I have a sharepoint site with name "Some - site" or simply "Site2".
The way I'm approaching this problem in code is like this:
var response = await client.Sites.GetAsync((reqConfig) =>
{
reqConfig.QueryParameters.Search = "Some - site";
// reqConfig.QueryParameters.Search = "Site2";
});
The request fails with the Status Code 400: BadRequest with message:
"Syntax error: character '-' is not valid at position 5 in 'Some - site'."
Same goes for using numbers in Search ("Site2").
When I was using Application permissions, I was able to retrieve .GetAllSites() and loop through them to find a specific site. However, I'm now using on-behalf-of flow with Delegated permissions and can't retrieve all sites, that's why I'm using Search query.
What would be a solution for this problem?