Getting exception for Microsoft Graph search query API(/search/query) driveItems

SHIVAKRISHNA 1 Reputation point
2021-09-08T11:38:25.723+00:00

API:
https://graph.microsoft.com/v1.0/search/query

Request Body:
{
"requests": [
{
"entityTypes": [ "driveItem"],
"query":
{
"queryString": "contoso"
}
}]
}

Problem:
When I run the search query API from the Graph explorer with above request body, I’m getting below error:

Error:

error 500 "code":"System.NotSupportedException",
"message":"\r\n Provenance None is not supported for conversion to ContentSource",
"innerError":{"date":"2021-08-03T11:20:56","request-id":"86c3fcd0-3346-425f-8f68-445f03b38d37","client-request-id":"d3084257-2f9e-7634-9632-4c3152812fda"}}

But I’m expecting the response as below:

Response:
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#search",
"value": [
{
"searchTerms": [
"contoso"
],
"hitsContainers": [
{
"total": 1,
"moreResultsAvailable": false,
"hits": [
{
"hitId": "FlULeN/ui/1GjLx1rUfio5UAAEl",
"rank": 1,
"summary": "<c0>Contoso</c0> Detailed Design <ddd/>",
"resource": {
"@odata.type": "#microsoft.graph.driveItem",
"createdDateTime": "2019-06-10T06:37:43Z",
"lastModifiedDateTime": "2019-06-10T06:37:43Z",
"name": "web_part_test_long Notebook",
"webUrl": "https://contoso.sharepoint.com/sites/contoso-team/contoso-designs.docx",
"createdBy": {
"user": {
"displayName": "Michaelvincent Santos;Provisioning User"
}
},
"lastModifiedBy": {
"user": {
"displayName": "Richard Mayer"
}
},
"parentReference": {
"siteId": "m365x231305.sharepoint.com,5724d91f-650c-4810-83cc-61a8818917d6,c3ba25dc-2c9f-48cb-83be-74cdf68ea5a0",
"driveId": "da61a2b0-4120-4a3f-812b-0fc0d79bf16b",
"sharepointIds": {
}
},
"fileSystemInfo": {
"createdDateTime": "2019-06-10T06:37:43Z",
"lastModifiedDateTime": "2019-06-10T06:37:43Z"
}
}
}
]
}
]
}
]
}

I also tried from NodeJS code using sdk (@microsoft/microsoft-graph-client) with below code:

const searchResponse = {
requests: [{
entityTypes: ['driveItem'],
query: {queryString: 'contoso'}
}]
};
await client.api('/search/query')
.post(searchResponse);

And also I tried changing the consent permissions, but still getting the same error.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,069 questions
{count} votes