You need to sign in to do that
Don't have an account?
Steven Nsubuga
Elastic Search scroll_id
I need to get data from a web service that only returns 10 records at a time. Even when I set the size parameter to a higher number, I still only get 10 records. The web service owners tell me I must use the scroll_id from elastic search.
Below is my code
The last class is used to parse the json and in there I am able to access the scroll id parameter.
I need help setting up the code to run continuously/recursively until all the records are returned. Anyone willing to help me on this? I do not want to keep
Below is my code
HttpRequest req = new HttpRequest(); req.setEndpoint('https://aa.bb.org/bdo/2.3.0/-eligible-for-af'); req.setMethod('POST'); req.setHeader('Authorization', 'Bearer eeee-gggg-hhhh-ijkl'); System.JSONGenerator gen = System.JSON.createGenerator(true); gen.writeStartObject(); gen.writeFieldName('query'); gen.writeStartObject(); gen.writeFieldName('match_all'); gen.writeStartObject(); gen.writeEndObject(); gen.writeNumberField('size', 500); gen.writeEndObject(); String pretty = gen.getAsString(); req.setBody(pretty); Http httpReq = new Http(); HttpResponse res = httpReq.send(req); json = res.getBody(); AfJSON2Apex afWithFinance = AfJSON2Apex.parse(json);
The last class is used to parse the json and in there I am able to access the scroll id parameter.
I need help setting up the code to run continuously/recursively until all the records are returned. Anyone willing to help me on this? I do not want to keep
You can try to use Batch Class (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch.htm). Http callouts has per transaction limits (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_timeouts.htm#:~:text=A%20single%20Apex%20transaction%20can,the%20maximum%20is%20120%2C000%20milliseconds.) of 100(Something to keep in mind when making bulk http callouts).
Thanks