Fetching API Response from Eclipse Java not working

So I am trying to fetch this API response but have not been able to the problem. when I call this below function and debug it at a certain point it fetches the result but as soon as it crosses if block the response disappears. Look at the two images for reference.

Here is the code for that function

public JsonObject getResult() {

    System.err.println(" Called getResult: "); 
    Request request = new Request.Builder()

    try (var response = client.newCall(request).execute()) {
        if (!response.isSuccessful()) {
            throw new IOException("Unexpected code " + response);

        ResponseBody responseBody = response.body();
        String responseBodyString;

        if (responseBody != null) {
            responseBodyString = responseBody.string();
        } else {
            throw new IOException("Response body is null");

        JsonObject js = gson.fromJson(responseBodyString, JsonObject.class);

        return js;

    } catch (IOException e) {
        System.err.println("[ERROR] " + e.getMessage());
        // TODO Try again in x minutes
        System.out.print("No Response");
        System.err.println("[ERROR] No Response");
        return null;

Hi Hatim,

sorry If I didn’t get the context properly, but how is this related on OpenEMS?

There are some similar Codes in OpenEMS currently e.g. for getting time-of-use prices from webservices. Maybe this helps? → openems/CorrentlyImpl.java at develop · OpenEMS/openems · GitHub

Also there is a proposal for a general HTTP worker currently open: Implement Generic HTTP Worker by nicoketzer · Pull Request #2098 · OpenEMS/openems · GitHub