0

I am having trouble using the new Office 365 Unified API for searching for email. I would really appreciate it if I could get some help.

I get the following error:

{"error":{"code":"ErrorInvalidArgument","message":"The value specified for search scope 'PrimaryMailbox' is invalid."}}

I was able to get the access token for graph.microsoft.com and retrieve all the messages from my inbox by doing a GET to "https://graph.microsoft.com/beta/me/messages".

However, when I add the search parameter $search="Tomcat", I get the error copied above. Any ideas how I can resolve this? Is there any documentation to clarify this? I have searched the Office Dev Center documentation in detail but could not find anything to help with searching in the Unified API. Eventually, I want to use the Unified API to search for users' contacts, calendar entries, OneDrive files, and SharePoint online.

On a related note, I can successfully search for mail messages using the existing Office 365 API by making a GET call to "https://outlook.office365.com/api/v1.0/me/messages". However, I am more interested in the streamlined Unified API approach and hope I can resolve the above issue.

Also, is there a way to search all mailboxes in a single search using either the existing API (https://outlook.office365.com) or the new Unified API (https://graph.microsoft.com/)?

Thanks.

Mohammad

San Jose, CA

MrPiao
  • 688
  • 5
  • 19
rc1
  • 483
  • 4
  • 19

2 Answers2

1

The Unified API preview documentation lists all supported query parameters, and $search isn't included. It does support $filter, so you can do some basic searches using that.

The Mail API does support $search, but there is no way to search across multiple mailboxes in one query.

Jason Johnston
  • 17,194
  • 2
  • 20
  • 34
  • Hello Jason, On an related note about Unified API and using OneDrive API for OneDrive for Business, the release notes (https://dev.onedrive.com/odb-preview/release-notes.htm), it says that one of the OneDrive API features not yet implemented for OneDrive for Business is the view.search action. Do you have any idea when this function (even in preview mode) will be available? – rc1 Jun 11 '15 at 07:05
0

You can use the below conditions for searching in outlook

  1. to search in particular folder(Ex: Drafts,Inbox)--/me/MailFolders/Inbox/messages?$search={1} : where 1 will be your search text
  2. If you want to search in all folders then /me/MailFolders/Allitems/messages?$search={1}: where {1} is the text you want to search
Mike Samuel
  • 118,113
  • 30
  • 216
  • 245
bavani
  • 1
  • 1