select Id, Name from Contact where Email in ('apple+super@gmail.com','apple+100@gmail.com')

Can anyone help me to query this using the salesforce query api endpoint.

The endpoint that I have tried


and the response that I get is:

    "totalSize": 0,
    "done": true,
    "records": []

Records are present in salesforce but the result is not displayed.

I even tried escaping query string with "\". The URL that I used is:


and the malformed query is the resulting respone.

What will be the correct way to query my SOQL using "IN" clause?

Thanks in advance

  • 1
    ytiq has provided the answer, but workbench is always available for you to try to figure out the right format as well and quickly test. Utilities --> REST Explorer Dec 31, 2019 at 13:14
  • update response with code for 'IN' and also added escaping for '+'
    – ytiq
    Jan 2, 2020 at 7:52

1 Answer 1


You should put ' ', but you don't need to escape them try that one https://{myWorkplaceDomainUsed}--sandbox.cs67.my.salesforce.com/services/data/v42.0/query/?q=select+Id+from+Contact+where+Email='apple+super@gmail.com'.

If you want IN you can use it like this https://{myWorkplaceDomainUsed}--sandbox.cs67.my.salesforce.com/services/data/v42.0/query/?q=select+Id+from+Contact+where+Email+IN+('apple+super@gmail.com', 'email@test.com')

UPDATE: Code for IN close with escaping for '+' emails

List<String> emails = new List<String>();
// init emails;

String emailString = '(\'' + String.join(emails, '\', \'') + '\''.replaceAll('\\+', '\\\\+');

String query = '... Email IN ' + emailString;
  • Ytiq, The IN clause query works fine when I don't have any email with the "+" character sign on it. When there is the "+" character it simply returns no record at all. Looks like this thinks "+" as space. As I think the single quote ( ' ' ) should avoid the inside quote character as string right? Could you please help me on querying an email with "+" sign in it. Thank you! Jan 1, 2020 at 4:14
  • Also My Email address will be a dynamic variable. Jan 1, 2020 at 4:27
  • Then uriEncode +, thought maybe it's a space. Didn't know that email can have +
    – ytiq
    Jan 1, 2020 at 6:32
  • Just add your variable as a string `'Select... Email=\''+variable+'\'...'
    – ytiq
    Jan 1, 2020 at 6:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.