I am dealing with an API that don't accept multi line json body and accept only 1 json line body (json compact form)
The below payload is valid because it's compact in just 1 line

And the below payload is not passing because it's multiline
I have the same problem in the Java/Spring code where I got this error while posting my object in restemplate.
Is there a way to convert the payload body into 1 single json line?
Code I am using to post the payload via RestTemplate
private HttpHeaders headers() {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(List.of(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN));
return headers;
}
post(ParameterizedTypeReference type, REQUEST myObject, URI uri) {
HttpEntity<REQUEST> entity = new HttpEntity<>(myObject, headers());
ResponseEntity<String> res = restTemplate.exchange(uri, HttpMethod.POST, entity , type);
}
