Title: Graph failure when using a hyphen (-) in a site name or a document library name in SharePoint Online
Description:
I encountered an error while verifying the following query in the Microsoft Graph Explorer:
Successful Query: When I send the following POST request, the query succeeds:
Query: https://graph.microsoft.com/v1.0/search/query
Request Body:
{
"requests": [
{
"entityTypes": ["drive"],
"query": {
"queryString": "sites/test/HPPKTest AND Path:\"https://hpqdstest.sharepoint.com/sites/test/HPPKTest\""
},
"fields": ["id", "webUrl", "parentReference"]
}
]
}
Response:
{
"value": [
{
"searchTerms": ["sites/test/HPPKTest"],
"hitsContainers": [
{
"hits": [
{
"hitId": "b!QDQjd4N5ukawPHXlLOe9ToBj09zb69BIhCCkjiJ_GjzMPRWZRUuMTr5qwyASXXLx",
"rank": 1,
"summary": "",
"resource": {
"@odata.type": "#microsoft.graph.drive",
"id": "b!QDQjd4N5ukawPHXlLOe9ToBj09zb69BIhCCkjiJ_GjzMPRWZRUuMTr5qwyASXXLx",
"parentReference": {
"sharepointIds": {
"listId": "99153dcc-4b45-4e8c-be6a-c320125d72f1"
},
"siteId": "hpqdstest.sharepoint.com,77233440-7983-46ba-b03c-75e52ce7bd4e,dcd36380-ebdb-48d0-8420-a48e227f1a3c"
},
"webUrl": "https://hpqdstest.sharepoint.com/sites/test/HPPKTest/Forms/AllItems.aspx"
}
}
]
},
"total": 1,
"moreResultsAvailable": false
}
]
}
],
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.searchResponse)"
}
Failed Query: When I send the following POST request, the query fails if the site or document library name contains a hyphen (-):
Query: https://graph.microsoft.com/v1.0/search/query
Request Body:
{
"requests": [
{
"entityTypes": ["drive"],
"query": {
"queryString": "sites/test/HPPK-Test AND Path:\"https://hpqdstest.sharepoint.com/sites/test/HPPK-Test\""
},
"fields": ["id", "webUrl", "parentReference"]
}
]
}
Response:
{
"value": [
{
"searchTerms": ["sites/test/HPPK-Test"],
"hitsContainers": [
{
"total": 0,
"moreResultsAvailable": false
}
]
}
],
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.searchResponse)"
}
It appears that the query fails specifically when a hyphen is included in the site or document library name.
Request: Could you please investigate this issue and provide a solution or workaround for using hyphens in site or document library names in SharePoint Online queries?
Thank you for your assistance.