Find your content:

Search form

You are here

Can you use the LIKE operator in SOQL queries via the REST API?

 
Share

As the title states, can you use LIKE in SQOL queries via the REST API?

Even with this basic query:

select Id from Account  where BillingState like 'VIC%' 

I'm getting an error back:

REST Response fault: [{"message":"SOQL statements cannot be empty or null","errorCode":"MALFORMED_QUERY"}]

Am I missing something obvious here?


Attribution to: Matt Lacey

Possible Suggestion/Solution #1

Yes you can. SOQL in the rest API supports all the same constructs that its SOAP older brother does. Remember to pass the SOQL as the 'q' parameter in the URL,and to URLEncode the soql when putting it in the query, e.g.

https://na1.salesforce.com/services/data/v25.0/query?q=select+id+from+account


Attribution to: superfell

Possible Suggestion/Solution #2

I think the issue is with the url encoding of the % in the like clause.

I just tried the following in the Workbench Rest API and it worked.

/services/data/v25.0/query?q=select+id+from+account+where+BillingState+like+'VIC%25'

Attribution to: Daniel Ballinger
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/818

My Block Status

My Block Content