Hi,
I am using two apis, the search api to search for an item and get api to retrieve that item
Search API :
curl --location --request POST 'https://graph.microsoft.com/v1.0/search/query' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data-raw '{
"requests": [
{
"entityTypes": [
"driveItem"
],
"query": {
"queryString": "dummy AND ContentType:Document"
}
}
]
}'
Response :
{
"value": [
{
"searchTerms": [
"dummy"
],
"hitsContainers": [
{
"hits": [
{
"hitId": "01HAMQQBUWJF3IOKRBYQ7ORSQ",
"rank": 1,
"summary": "<c0>Dummy</c0><ddd/>",
"resource": {
"@odata.type": "#microsoft.graph.driveItem",
"size": 79430,
"id": "01HAMQQBUWJF3IOKRBYQ7ORSQ",
"createdBy": {
"user": {
"displayName": "aaa",
"email": "aaa"
}
},
"name": "Dummy.pdf",
"parentReference": {
"driveId": "b!2Cpw3HmhMk2Jb4dABGdSh920Acn19YVJgsiBLTU0zzz",
"id": "01HAMQOAQOD66PGXDSYRDY",
"siteId": "zzzz.sharepoint.com,dc702ad8-12e2-4d32-896f-12r12r,c901b4dd-f5f5-4985-asfa-812d35340767"
},
"webUrl": "www.dummy.com"
}
}
],
"total": 453,
"moreResultsAvailable": true
}
]
}
],
"@odata.context": "microsoft.com"
}
Here we have siteId - zzzz.sharepoint.com,dc702ad8-12e2-4d32-896f-12r12r,c901b4dd-f5f5-4985-asfa-812d35340767
and ItemId - 01HAMQQBUWJF3IOKRBYQ7ORSQ
Now if I call the get(preview) item api
curl --location --request POST 'https://graph.microsoft.com/v1.0/sites/zzzz.sharepoint.com,dc702ad8-12e2-4d32-896f-12r12r,c901b4dd-f5f5-4985-asfa-812d35340767/drive/items/01HAMQQBUWJF3IOKRBYQ7ORSQ/preview' \
--header 'Authorization: Bearer {<!-- -->{accessToken}}'
The result is returned 404.
But the file is present on the system.
Access Token being used is Delegated Token