Why I’m not getting all the JSON objects from server when using OkHttp in android studio?

  android-studio, fetch, java, okhttp, server

What I have done : I’m using the OkHttpClient (I’m using okhttp3 package) client to fetch JSON strings from a server in Adroid Studio. Fetching and everything works well only when trying to fetch the lesser number of objects.

What I’m looking for: But, when I increase the number of objects to fetch, I don’t receive any output, sometimes very few are receiving.
Serverresponse becomes empty []. There are no errors visible in the log either. How to fetch all the objects from a server? I would appreciate any suggestions on this. Thank you!
(PS – I’m new to OkHttp)

OkHttpClient client = getUnsafeOkHttpClient();
String myUrl = new BackendLinks().endPoint + "objects/number";
Request request = new Request.Builder()
Response response = client.newCall(request).execute();
String responseString = response.body().string();

System.out.println("Server response: " + responseString);

Attempts: I tried printing status code and response headers and my observations are the same. As per the response code 200 it seems to be ok.

        System.out.println("Server Server: " + response.header("Server"));
        System.out.println("Server Date: " + response.header("Date"));
        System.out.println("Server Vary: " + response.headers("Vary"));
        System.out.println("Server HEAD: " + response.headers());
        System.out.println("Server Status: " + response.code());

I/System.out: Server Server: null
I/System.out: Server Date: Tue, 23 Feb 2021 22:17:21 GMT
I/System.out: Server Vary: [Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Origin, Access-Control-Request-Method, Access-Control-Request-Headers]
I/System.out: Server HEAD: cache-control: no-cache, no-store, max-age=0, must-revalidate
I/System.out: Server Status: 200

Source: Android Studio Questions