I am encountering an issue while searching threads using the Nylas API v3. Specifically, when I search with the keyword "MAN-45", I receive the following error:
{
“request_id”: “5282526796-ddd399af-c51d-4cbe-a7e5-0f4410fafec4”, “error”: { “type”: “provider_error”, “message”: “Bad Request”, “provider_error”: { “error”: { “code”: “BadRequest”, “message”: “Syntax error: character ‘-’ is not valid at position 3 in ‘MAN-45’.” } } }
}
The issue persists even when I search using only digits. However, searching with complete words containing only characters works fine. But if I use two-character words separated by spaces (e.g., "AN 45"), the search also fails.
Could you clarify the expected behavior for the search_query_native parameter in thread searches? I am following the documentation from this link:
I have tested searching in the Outlook app and other Microsoft inboxes using various queries. For example, when I search with subject ‘NDD-001100’, it returns the correct results. Similarly, searching with any number (e.g., ‘5678’), symbols (e.g., ‘- _ @’), or multiple words with spaces (e.g., ‘Test search’) works without issues.
However, when I try using the search_query_native parameter in the Nylas API, it fails and throws a syntax error for numbers, symbols, or spaces. Even though I followed the Nylas search documentation and encoded the URL properly, the issue persists.
I believe this is a problem with the Nylas API, and the backend team should investigate and resolve it as soon as possible. You can reproduce the issue by testing a search on any Nylas inbox.
Hi @Emmad_Altaf! I’m a software engineer at Nylas, thanks for raising this issue. It looks very reproducible, so I’ll be taking a look at it this week, and hope to get it resolved for you ASAP.
Hi @Emmad_Altaf I am so sorry, there were other issues I needed to attend to first, and this slipped out of my rader. I’m picking it up again today, and hope to have a response for you by EOD.
Hi @Emmad_Altaf - I’ve found the issue and am working on a fix. You can expect it to be in production by Friday. If it’s still not working by then (and if you have any more issues), please file a customer support ticket here as we do not track forums posts as rigorously.
Hi @Emmad_Altaf! We actually ended up not shipping any code change at all, and I’ll explain why.
To fix the issues you are seeing with strings like MAN-45, you need to wrap them in double quotes. So what you should be passing to search_query_native is “MAN-45” or %22MAN-45%22. Then, you should see the results you are expecting.
I believe there is also a bit of confusion here about what search_query_native actually does. It is not meant for you to directly copy what is in the UI search bar, and then pass it to this query param (although that is very close, but there is a subtle difference). Our intention is to allow you to query the providers using their native syntax. For the case of Microsoft accounts, that means using the $search query param provided by the Graph API, which powers the UI. The Graph API will return 400 Bad Request if you do not use the quotes like I showed above and pass in non-alphabet characters.