Reputation: 163
I have been battling with this for a while and cant find a solution. I am running the SpringBoot guides and the Accessing JPA Data (http://spring.io/guides/gs/accessing-data-rest/) with REST is not working.
Just downloading it and running it runs fine allowing a GET call to
http://localhost:8080/people
using POSTMAN. However whenever I try a PUT or POST I get the following error
{
"cause": null,
"message": "No suitable HttpMessageConverter found to read request body into object of type class hello.Person from request with content type of text/plain;charset=UTF-8!"
}
The json I am passing with the PUT is
{
"firstName": "Dave",
"lastName": "Something"
}
This is just running the vanilla project with no changes. Lots of the other guide projects work fine so I know MVN, Spring boot etc are working ok.
Have tried a lot of forums but nothing suggested works.
Any help would be greatly appreciated.
Thanks Dave
Upvotes: 14
Views: 8509
Reputation: 1
you can select Body->RAW->Json in the Api Client and try it. firstly I was using text that's why its giving me error.
Upvotes: 0
Reputation: 1
Make sure you have selected the
Body->RAW->Json in the Api Client and try it worked for me.
Upvotes: 0
Reputation: 721
I used Google Chrome's Postman extension and sent raw JSON { "firstName": "Frodo", "lastName": "Baggins" }
. That worked.
Keep in mind to specify the HTTP header Content-Type: application/json
.
Upvotes: 3
Reputation: 1434
Content-Type:application/json try to remove the space between content-type:* and application in the header .
Upvotes: 0
Reputation: 116091
Your POST request has a content type of text/plain
and the server doesn't know how to convert plain text into a hello.Person
instance.
You need to tell the server that you're sending JSON by setting the Content-Type
header of the request to application/json
Upvotes: 28