3

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.

  • The link for reference is: https://graph.microsoft.io/docs/api-reference/v1.0/api/item_search – Gustavo Alfonso Nov 25 '15 at 13:21
  • Thanks for reporting. I've filed a bug on this issue. Will update this item when it's fixed (if I remember ;)). I don't think this covers search across an org's SharePoint. This is something we are looking to add at a later date. – Dan Kershaw - MSFT Nov 27 '15 at 19:49

1 Answers1

2

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.

Marek Rycharski
  • 1,614
  • 11
  • 10
  • So with this changed URL I get back no results but no errors. So is this searching One Drive or Sharepoint, both? or does something else need configured to make it available for graph search? – Gustavo Alfonso Dec 02 '15 at 11:23
  • This URL can be used to search SharePoint only. To search OneDrive it would need to include a "me" segment, i.e. https://graph.microsoft.com/v1.0/me/drive/root/microsoft.graph.search(q='') – Marek Rycharski Dec 02 '15 at 18:32
  • https://graph.microsoft.com/v1.0/drive/root/microsoft.graph.search(q='') returns the same items as https://graph.microsoft.com/v1.0/drive/root/children for me. Could you check if the latter URL returns any results for you? – Marek Rycharski Dec 02 '15 at 18:37