0
votes

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

2

2 Answers

1
votes

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.

0
votes

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