Java and Request API

Java and Request API

Hi, 

  I am running some Java code that returns a JSON object from Requests API.  If I request any more that 100 records, it only returns 100 records.  If I run the same query through the api interface in Manage Engine ServiceDesk plus I get back the number of records I request.  Is there anything I am doing wrong?

public static JSONObject getRequestsJSONFromManageEngine() {
logger.trace("Entering getRequestsJSONFromManageEngine()");

JSONObject jsonObject = null;

try {

JSONParser parser = new JSONParser();
String urlStr = "https://<site redacted>/api/v3/requests?input_data="
+ URLEncoder.encode("{\"list_info\":{\"row_count\":101}}", StandardCharsets.UTF_8);
            URL url = new URL(urlStr);

HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("technician_key", "<key redacted>");

if (conn.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
}

BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));

Object obj = parser.parse(br);

jsonObject = (JSONObject) obj;
} catch (MalformedURLException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

} catch (Exception e) {
e.printStackTrace();
}

return jsonObject;
}

Dave

                  New to ADSelfService Plus?