How to specify BatchSize in Rest API SOQL call, I tried it as per salesforce documentation and its not working ?
Note - I know you can do this using offset, but I wanted to explore if its possible using BatchSize.
Sample Code (I added this code in visualforce page) -
jQuery(document).ready(function($) {
// Pull 10 Accounts via the REST API
$.ajax('/services/data/v28.0/query?q=SELECT+Name+FROM+Account+LIMIT+10',
{
beforeSend: function(xhr) {
// Set the OAuth header from the session ID
xhr.setRequestHeader('Authorization', 'Bearer {!$Api.Session_ID}');
xhr.setRequestHeader('batchSize', '5');
},
success: function(response) {
// We got 'em - append our records to the HTML list
$.each(response.records, function(index, record) {
$('#accountList').append('<li>'+record.Name+'</li>');
});
},
error: function(jqXHR, textStatus, errorThrown) {
// Oops - what went wrong?
alert(jqXHR.status + ': ' + errorThrown);
}
}
);
});
This code still gives me 10 accounts instead of 5 accounts.