Skip to content
Advertisement

How create unit test in Spring REST in POST Cotroller

I have a Spring Boot Controller with POST. Method works fine. I tested it by POSTMAN and from postgresql I recieved JSON. But I need test it.

JavaScript

I created test:

JavaScript

when I run a test, I received error like below:

JavaScript

What am I doing wrong?

Advertisement

Answer

The problem is this line:

JavaScript

Right now you are sending the object in the content-type header, that’s why you get the error message.

Change it to:

JavaScript
Advertisement