Community
Showing results for 
Search instead for 
Do you mean 
Reply

Calling API Search Using 'Contains' Match

Accepted Solution Solved
Highlighted
Copper Elite Contributor
Posts: 118
Country: United_Kingdom
Accepted Solution

Calling API Search Using 'Contains' Match

We're attempting to use the Act! web API to interact with an external application & have an issue with the contact search API.

 

I have a “search” screen that has 3 criteria fields – company name, serial number and postcode – which correspond to fields in Act! (i.e. 2 standard Act! fields, and a custom field for the serial number. 

 

I want Users to search for a combination of these 3 fields that is tolerant of blank fields – if they don’t enter a value, we don’t search by it.

 

For example, the API URL we're calling is:

 

http://<DOMAIN>/Act.Web.API/api/Contacts?$filter=contains(company, 'Alexander') and contains(busines...

 

And I get the message back from the API:

 

Unable to cast object of type 'Microsoft.OData.Core.UriParser.Semantic.SingleValueFunctionCallNode' to type 'Microsoft.OData.Core.UriParser.Semantic.BinaryOperatorNode'.

 

If I search on each of the 3 fields independently (i.e. just company OR just serial number OR just postcode) the search works fine – so I’m fairly sure my “contains” syntax is correct – it just doesn’t seem to like the “and”. E.g. all these work as expected:

 

http://<DOMAIN>/Act.Web.API/api/Contacts?$filter=contains(company, 'Alexander')&$top=1000

http://<DOMAIN>Act.Web.API/api/Contacts?$filter=contains(businessAddress/postalCode, 'rh10')&$top=10...

http://<DOMAIN>/Act.Web.API/api/Contacts?$filter=contains(customFields/user2, '3-0123-456789')&$top=...

 

If I modify my query to do an exact match instead of a “contains”, I can use “and” in the query perfectly happily – it’s just that the user has to enter the exact details as they are in Act! E.g.:

 

http://<DOMAIN>/Act.Web.API/api/Contacts?$filter=company  eq 'Alexander' and businessAddress/postalCode eq 'rh10'&$top=1000

 

I'd be grateful for any ideas?

 

Thanks

 

Will Ingleby

 


Will Ingleby
ACT! Certified Product Specialist

Solutions for Accounting & CRM (UK)


Accepted Solutions
Solution
Accepted by topic author will@bluebirdsam.com
‎02-03-2017 09:19 AM
Employee
Posts: 236
Country: USA

Re: Calling API Search Using 'Contains' Match

Hi,

 

Thank you for the detailed post, very helpful.  you've highlighted a current gap in the API query capabilities:  we don't yet support complex queries that combine contains, startswith, or endswith with an AND clause, but absolutely something we want to support.

 

 

View solution in original post


All Replies
Solution
Accepted by topic author will@bluebirdsam.com
‎02-03-2017 09:19 AM
Employee
Posts: 236
Country: USA

Re: Calling API Search Using 'Contains' Match

Hi,

 

Thank you for the detailed post, very helpful.  you've highlighted a current gap in the API query capabilities:  we don't yet support complex queries that combine contains, startswith, or endswith with an AND clause, but absolutely something we want to support.