+ Start a Discussion

How to retrieve more than 2000 records returned from the rest api in Salesforce ?

Hi Expert,

how to retrieve more than 2000 records returned from the rest api in Salesforce.
When I execute the below query through rest api then it will return only 2000 records.
https://" + instanceName + ".salesforce.com/services/data/v35.0/query?q='SELECT+Id,Name,ParentId,Phone,Website,Description,OwnerId+FROM+Account'

I'm stuck on this salesforce limit.
Help on this how to get more than 2000 records through rest api.

Thanks & Regards
Mukesh Kumar
Hi Rahul,

Thanks for reply.I have visited all these link but this is not worked in my code.
Actualy I'm call Rest Api through Jquery and in the jquery return only 2000 Records.

snipet of code
ChromeForce.prototype.callRestApi = function(path, method){
        var deferred = $q.defer();
            method: method,
            url: this.getServiceEndpoint(path),
            headers: {
                "Authorization": "Bearer " + sessionId
        }).then(function successCallback(response) {
            return deferred.resolve(response);
        }, function errorCallback(response) {
            return deferred.reject(response);
        return deferred.promise;

api.callRestApi('/query?q=' + soqlquery_kld, 'GET')
                        $scope.myOrganization = response.data.records;
                        Soql_filter_Records = response.data.records;
                        $scope.isSpinShow = false;
                        $scope.NoofRecords123 = false;
                        $scope.OnlyOneRecord = false;
                        if (response.statusText == 'OK') {
                            $scope.isResponseOk = true;
                        $scope.TotalNumberOfRecords = response.data.totalSize;

                    }, function(err){
                        $scope.myOrganization = $scope.err;
                        $scope.isLoading = false;
                        $scope.errorMessage = $scope.err;
                        $scope.isSpinShow = false;
                        $scope.IsError = true;

Mukesh Kumar