'Get all Body request using foreach loop on ArrayList on unirest in Java
I have an arraylist i.e.
ArrayList<Integer> getStoresId = [1845, 1846, 1847]
Now I have to execute an end point everytime on each of these id's, e.g. End point is like this:
https://endpoint/stores/1845/timeEntries,
and i have use this on every storeID. for which I am using following logic:
public static JSONObject getAllTimeClocks() throws IOException, UnirestException {
ArrayList<Integer> getStoresId = [1845, 1846, 1847]
HttpResponse<JsonNode> bodyResponse = null;
for (Integer id : getStoresId) {
bodyResponse = Unirest.get(url + id + "/TimeClockEntries").header("x-access-token", token).asJson();
}
assert bodyResponse != null;
return bodyResponse.getBody().getObject();
}
and everytime, it is returning me 'null', I need to know, what I am doing wrong.
NOTE: Many of things here are not shared, i.e. token, url etc.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
