'Salesforce report API - How to fetch more than 2000 records from Salesforce?

In salesforce, I have a report that has more than 2000 records (40000 rows). When I am trying to get that report via API I am getting only 2000 rows. It seems there is a limit of 2,000 results that can be returned for a given request. I am using the below code to get the data.

                    URIBuilder builder = new URIBuilder(salesforceConnection.getInstanceUrl());
                    builder.setPath("/services/data/v39.0/analytics/reports/" + recordId);
    
                    final HttpGet get = new HttpGet(builder.build());
                    get.setHeader("Authorization", AppConstants.BEARER + salesforceConnection.getAccessToken());
                    final HttpResponse queryResponse = httpclient.execute(get);

Is there a way to query the remaining data?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source