Ich verwende RestTemplate von org.springframework:spring-web:6.2.8
Auf der Gegenseite wird folgende Fehlermeldung ausgegeben:
JSON Exception: unexpected end of text
Java:
@Autowired
private RestTemplate restTemplate;
@PutMapping("putTimeSettings")
@CrossOrigin
public void putTimeSettings(@RequestParam String id, @RequestBody TimeSettingsStatusDTO dto, HttpSession session) {
try {
final JSONObject jsonObject = mapStatusDTOToJsonObject(dto);
String url = ipAndPortOfDeviceConfigServiceApp + baseUrl + "?ID=" + id;
restTemplate.put(url, jsonObject);
} catch (Exception e) {
logger.error("error in saving the object {}", (Object[]) e.getStackTrace());
throw new RuntimeException("");
}
}
private JSONObject mapStatusDTOToJsonObject(TimeSettingsStatusDTO dto) {
try {
final JSONObject jsonObject = (JSONObject) new JSONParser().parse(new Gson().toJson(dto));
return jsonObject;
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
Auf der Gegenseite wird folgende Fehlermeldung ausgegeben:
JSON Exception: unexpected end of text