Getting no suitable HttpMessageConverter found for response type

1.3k Views Asked by At

org.springframework.web.client.UnknownContentTypeException: Could not extract response: no suitable HttpMessageConverter found for response type [class net.minidev.json.JSONObject] and content type [application/json]

public String handleRequest(ScheduledEvent event, Context context) {
    LambdaLogger logger = context.getLogger();
    String requestBody = System.getenv().get("REQUEST_BODY");
    String endpointUrl = System.getenv().get("ENDPOINT_URL");
    String authorizationHeader = System.getenv().get("AUTHORIZATION_HEADER");
    ResponseEntity<JSONObject> response = restTemplate.getForEntity(endpointUrl, JSONObject.class);
    logger.log(response.getBody().getAsString("Total document signed"));
    String lambdaResponse = new String("200 OK");
    return lambdaResponse;
}

endpointUrl also returns JSONObject so not getting why the mismatch

1

There are 1 best solutions below

0
On

The resttemplate converters dont convert to a JSONObject directly.

you can alter it so that restTemplate gives the response as a string, which can then be converted as JSONObject.