I am attempting to run a REST API Query against my org. The following query selects all of the fields from 'Account' where the name equals a string and the record type equals a specific record type. However, every time I add the word "AND" it is failing with a "bad message 400" "unknown version".

Here is the query...


Why do I get this error? How can I fix it?

Edit: Full URL

  • Your post would be much easier to read if you remove all fields from your SELECT clause except Id.
    – Adrian Larson
    Aug 15 '19 at 18:50
  • No need to + before and after '='. Remove and retry, should work
    – Raj
    Aug 15 '19 at 19:10
  • Nope... doesn't work
    – coder42
    Aug 15 '19 at 19:18
  • What's the full URL you're using to call this API
    – identigral
    Aug 15 '19 at 19:24
  • Can you make sure if that recordtype name exists in Account object? Or/AND make sure you have an account with name 'Shop'. I do not see any issue at all with the query.. i tried with similar query and did not get any error at all..
    – Raj
    Aug 15 '19 at 20:18

Two things: First: The single quotes must be URL encoded. The URL code for a single quote is %27 so like this:


Second: The dot in RecordType.Name is most likely the root of the problem. Normally you should not use a dot in the URI parameters. You can try encoding the dot with %2E or use the encoding utility to encode the whole query string:

String qStr = 'https://my_org_name.my.salesforce.com/services/data/v45.0/query/?q=SELECT Id FROM Account WHERE Name=\'SHOP\' AND RecordType.Name=\'Property\'";
String encodedqStr= EncodingUtil.urlEncode(qStr, 'UTF-8');
  • /services/data/v45.0/query/?q=[SOQL query] is part of the standard REST API, and so the developer does not have the ability to change how it works. The SO post you referenced is about having a resource represented by a single period, not about an inability to ever have periods in valid URLs ever. The whole query needs to be URL encoded, but that's it. Aug 15 '19 at 21:00
  • Oh interesting I wasn't aware SOQL queries are supported as URI params. Then perhaps encoding the URL may work.
    – atomCode
    Aug 15 '19 at 21:09

Its unclear if you are actually able to save it without the escape character \. It should actually not even compile and save. However, I just checked below in my org and its working:


Note: Ofcourse my_org_name is changed to my domain.

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.