Search code examples
ruby-on-railssearchrequestoffice365office365api

Search emails using Office 365 REST API


I'm using Ruby on Rails and Office 365 REST API to get messages with $search params. My request look like that

https://outlook.office.com/api/v1.0/me/folders/inbox/messages?$search="oundatio‌n"

This request can not search emails contain "Foundatio‌n", it just can find emails have exactly "oundatio‌n" word. I want to search all emails have words contain "oundatio‌n" like "Foundatio‌n", "Soundatio‌n"... oundatio‌n .... Could you help me? Thank you very much!


Solution

  • The Outlook v1.0 REST API's search function uses the Advanced Query Syntax. As such, you can only search for a partial string if you know the beginning of that string. If you only type the end or middle part of the string, only results that begin with that part will be returned. For instance, if you were to look for my "foundation", then typing "found" will give the expected results. Only typing "ation" will not return the correct results.

    Using a common wildcard character such as * will not make any difference since wildcards are not supported. As special characters are ignored in general, searching for "oundation" or "*oundation" will return the same results.

    You can find further clarification on AQS's search syntax here, and you can test your queries in the Outlook OAuth Sandbox.