First time post here and I'm quite new to the SF ecosystem as well. I'm currently trying to figure out how to properly form queries using SOQL + REST.

Ideally what I am trying to do is query an endpoint like:


I've read a few different ways to go about doing this, but I'm not sure if creating a query like this is the best way, or it using the query() endpoint is better.

I'm just looking for some guidance on pulling back open opportunities at this point.


Your query does not use valid syntax. There are a few things you need to fix:

  • Your SELECT clause must contain a comma delimited list of fields to return
  • You need a FROM clause that tells the system which object to query
    • The API Name of the object you are trying to query is Opportunity, not Opportunties
  • You cannot use a LIKE clause on Id values. If you have an exact value to filter on, use =
  • If you want to pull back all open Opportunity records, filter on the IsClosed field.

If you're going to use the REST API, note also from Execute a SOQL Query in the Force.com REST API Developer Guide that you have a couple more issues you need to fix in your endpoint path:

  • You must add /query/ after the version (i.e. /v37.0/query/?q=...)
  • You must start with a leading slash (i.e. /services/...)

Putting it all together, you are looking for something along these lines:

  • Thank you for the feedback. The query you provided did work for what I was looking for. I appreciate the link as well - everyone seems to write their queries differently, so I'm just trying to learn best practices before I get too far into it. – confusedandamused Jan 30 '17 at 16:38
  • what about if i want to write something like that >> Select AccountId, Name, Account.Name from Contact where Name like '%john doe%' << should i put '+' between john and doe !? – KhogaEslam Jun 30 '19 at 20:15
  • You should post that as a separate question. Please refrain from asking questions via comment. – Adrian Larson Jun 30 '19 at 20:17

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.