function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Andy PeelAndy Peel 

"limit" query parameter doesn't work with REST API

My resultset is restricted to 2000 records, even though I'm asking for 50. Example query URL:

https://blah.my.salesforce.com/services/data/v20.0/query?q=SELECT+Name+FROM+Contact&limit=50

Docs here describe limit query parameter: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_search_suggest_queries.htm?search_text=limit
pconpcon
Your URL is wrong.  You have & and you want +
 
https://blah.my.salesforce.com/services/data/v20.0/query?q=SELECT+Name+FROM+Contact+limit=50

Checkout this site [1] to URL encode your query.  I'd recommend using the RFC2396 mode to replace spaces with +

[1] http://www.albionresearch.com/misc/urlencode.php
Andy PeelAndy Peel
The documentation says that q and limit are query parameters, so it's correct to use & to separate them.

If I change it to a +, the limit becomes part of the query, which might work in SQL, but not in SOQL. I tried it and got MALFORMED_QUERY.
pconpcon
I assure you that limit works as part of SOQL.  The reason you are getting a malformed query error is likely because you are using a very outdated version of the API.  If you change v20.0 to the most recent version of 36.0 the query I provided will work.
 
https://blah.my.salesforce.com/services/data/v36.0/query?q=SELECT+Name+FROM+Contact+limit=50