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