问题
We are using the Microsoft Graph API (new, Office365 unified API renamed to this recently). We have an OAUTH login, with the graph.microsoft.com
resource used to generate a token. It works fine to get other subresources such as /me
. But when using the URL in Microsoft Graph's documentation that talks about searching drive (and SharePoint?) we cannot find a way to make any sample URL work. It doesn't work when a drive is available for the user nor when SharePoint.
So first question, why does this generate an error?
GET https://graph.microsoft.com/v1.0/drive/root/Microsoft.Graph.search?q=img
Rreturns a bad request:
Error: 400 - Bad Request
See Response Headers for details.
{
"error": {
"code": "BadRequest",
"message": "Unsupported segment type.",
"innerError": {
"request-id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"date": "2015-11-23T16:58:26"
}
}
}
Here is the Response Header:
Transfer-Encoding: chunked
request-id: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
client-request-id: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"West US","Slice":"SliceB",
"ScaleUnit":"002","Host":"AGSFE_IN_4","ADSiteName":"WST"}}
OutBoundDuration: 0
Duration: 2.2283
Cache-Control: private
Date: Mon, 23 Nov 2015 16:58:25 GMT
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
And second part of the question, does this also search Sharepoint as it hints? There is no separate API for doing so within the graph API.
回答1:
The correct request URL is https://graph.microsoft.com/v1.0/drive/root/microsoft.graph.search(q='img')
I created https://github.com/OfficeDev/microsoft-graph-docs/issues/51 to correct the documentation.
来源:https://stackoverflow.com/questions/33878180/trying-to-search-sharepoint-files-using-microsoft-graph-api