Forum Discussion
Sharepoint Search with app permission
Hi there,
I'm trying to query SharePoint Online with GraphAPI to get specific files. Therefore, I've created an app registration with Sites.ReadAll application permission. The URI I use is https://graph.microsoft.com/beta/search/query and my body looks like this:
{
"requests": [
{
"entityTypes": [
"driveItem"
],
"contentSources": [
"/sites/mytestsite"
],
"query": {
"queryString": "filetype:docx"
},
"region": "f4eea532-32e8-41f6-a4d7-367a7ba205a7"
}
]
}
The error message I get is:
error : @{code=System.Exception; message=SearchRequest Invalid (EntityRequest Invalid (Content Source is
required only for ExternalItem))
Content Source is required only for ExternalItem; target=; httpCode=400}
Instrumentation : @{TraceId=22324833-2f63-dbbc-0309-2a73835982ce}
However, if I post this request without the content source value, I get this:
{
"requests": [
{
"entityTypes": [
"driveItem"
],
"query": {
"queryString": "filetype:docx"
},
"region": "f4eea532-32e8-41f6-a4d7-367a7ba205a7"
}
]
}
error : @{code=System.AggregateException; message=
One or more errors occurred. (ContentSources is empty)
ContentSources is empty; level=Error; httpCode=500}
When using delegated permissions, it works without problems. Anyone had the same issue?
Thanks!
1 Reply
- utilitydeltaCopper Contributor
I would also like an answer for this one!