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?

  • If you're still having problems post your code
    – superfell
    Commented Aug 23, 2012 at 2:00

2 Answers 2


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.


  • 3
    Yup, just realised the problem was that I wasn't encoding the % sign. I'd actually tested encoding using what turns out to be a broken encoder online, it told me that % is just %, not %25!
    – Matt Lacey
    Commented Aug 23, 2012 at 2:05
  • 2
    Try using workbench.developerforce.com next time to formulate the SOQL query / REST request Commented Aug 23, 2012 at 13:10

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.

  • Giving the accept to to @superfell because he got in there first, I just couldn't accept it within 10 minutes of asking it seems!
    – Matt Lacey
    Commented Aug 23, 2012 at 2:10
  • Yes. Totally fair. I got distracted by my day job and when I turned back @superfell had the answer sorted. Commented Aug 23, 2012 at 2:12
  • @DanielBallinger hmm, day job - remind me what's that?
    – Saariko
    Commented Aug 23, 2012 at 7:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .