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
  •  | 
  •  

문제

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?

도움이 되었습니까?

해결책

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!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top