SFDC returns a BadRequest: URI Scheme is too long for the following query.

services/data/v39.0/query/?q=SELECT Id, Name FROM Contact WHERE Viewer_Locked_By_Date_UTC__c < 2017-12-05T22:39:37Z LIMIT 2000 OFFSET 0

I believe it has something to do with:

Viewer_Locked_By_Date_UTC__c < 2017-12-05T22:39:37Z

But don't know why...can anyone explain how to compare a DateTime via Force.com API?

1 Answer 1


You've got two issues. First, you forgot the FROM <ObjectName>. Second, you need to encode your spaces as %20. The final result should look something like this:


(Line break added for legibility and should not be included in the actual URL).

  • Valid reply, but I expect the tooling (.net client) to encode. Accidentally deleted my from statement. I will add one in as you suggest.
    – tmc
    Dec 5, 2017 at 23:26
  • @tmc I haven't seen a client that does this automatically, on the assumption that it could get it wrong (URI path and URI query parameters are encoded differently). Check the manual for your language to confirm.
    – sfdcfox
    Dec 5, 2017 at 23:29
  • I wish I could up vote you, as it appears to be something in the client. Query works in the Develop Console.
    – tmc
    Dec 5, 2017 at 23:33
  • The developer console does the encoding for you when you use the Query tab. If you're using, say, the REST Explorer, you have to do it yourself.
    – sfdcfox
    Dec 5, 2017 at 23:36
  • Unfortunately, Uri Escaping did not solve my issue. I am thinking there may be a .Net bug or something. I will try the REST explorer. Thanks for the tip!
    – tmc
    Dec 5, 2017 at 23:40

You must log in to answer this question.

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