RestTemplate returns empty JSONObject but works with String

Viewed 93

When I run

ResponseEntity<JSONObject> response = queryToRest.exchange(uri, HttpMethod.GET, new HttpEntity<>(headers), JSONObject.class);

the function returns 200 and an empty body {}

I need to run

ResponseEntity<String> response = queryToRest.exchange(uri, HttpMethod.GET, new HttpEntity<>(headers), String.class);

to get my content and then convert it to a JSONObject.

How to directly have a JSONObject? Do I need to add some parameters to my RestTemplate queryToRest object?

This used to work fine under spring 1.5 but not right now with spring 2.1 (idk if it is the reason)

0 Answers
Related