Urlencoded Search containing apostrophe (')

Originally posted by Michael Knight

Im hoping there is a simple answer to this that someone has come accross or Cody can answer.

using URLencoded filtered search of contacts and am getting advanced filtering is not available

The contact i am trying to search for is called “Domino’s - Joondalup”

My urlencoded search is

https://api.servicem8.com/api_1.0/company.json?$filter=name%20eq%20’Domino’s - Joondalup’

I am receiving an error saying that advanced filtering is not available. Im assuming this is because it is parsing the apostrophe in domino’s and treating it as a filter parameter.

has anyone else come accross this an is there a way that you can escape the apostrophe so it is parsed as par of the string and not the filter.

I have a similar issue.

I have created a note pointing to a Business Central Customer card.

The note looks like……

If I right click on the URL, is passes everything up to the equals sign to the browser - and the way Business central works is that the very first customer in the system is displayed.

If however I copy the entire URL from the note and paste it into my browser, the actual customer I am interested in is displayed.

Looking at the actual note it appears that the URL is finished once it hits the first ‘ (single quote)

Epiphany time - I just constructed the filter with %27 replacing single quotes and the complete URL is there - and the link works.

The link (just the back end of it looks like………..

image

So - if anyone else has the same issue…………

Stan

Hi Stan,

Good pickup. In the ServiceM8 REST API, string values in a $filter expression are wrapped in single quotes, and when the request is URL-encoded those quotes appear as %27. The /company.json endpoint supports this kind of result filtering.

If an exact name eq '...' filter gets messy with characters like apostrophes, an alternative is to use /search.json?q=... to find the matching company, then use the returned UUID in later requests (filtering on fields like uuid is recommended for best performance).

If you’re still seeing “advanced filtering is not available” after URL-encoding the full filter expression, email support@servicem8.com with the exact request URL and response body.

Thanks,
Cody