How to extract the value of serialized JSON String out of the POST HttpRequest with spring Resttemplate

StackOverflow https://stackoverflow.com/questions/23662125

  •  22-07-2023
  •  | 
  •  

Pergunta

I'm trying to send an object with a POST HttpRequest in restTemplate.

restTemplate.postForObject(urlPOST, "POST", Some.class, someObject);

For debugging purposes i would like to get the serialized JSON string from the object out of springs restTemplate.

Where and how can I get access the json string that is sent to the server?

Foi útil?

Solução

You can set your breakpoint at the class

public abstract class AbstractHttpMessageConverter<T> implements HttpMessageConverter<T>

in the Method

public final void write(T t, MediaType contentType, HttpOutputMessage
 outputMessage)

to see what the converted string!

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top