Roopesh Majeti
Roopesh Majeti

Reputation: 554

json parsing error in Springboot

I have a simple springboot program which takes a json and prints it. The main intention was to do json validator package usage, but the current context is on the basic request parsing. The problem is when i tryy to map the input request into an class entity, it is giving the below error : "org.springframework.http.converter.HttpMessageNotReadableException",.

Sample input request in the body : {"name":"Roopesh", "no":123123}

Upvotes: 0

Views: 47707

Answers (2)

Kundan Atre
Kundan Atre

Reputation: 3961

Incase if you are using Postman client to test your Rest API, there are chances wherein you must be adding body in under tab "form-data" rather "raw".

Upvotes: 5

invenit
invenit

Reputation: 424

You send incorrect request. Use curl -X POST localhost:8090/one -H 'content-type: application/json;charset=UTF-8' -H 'name: test' -H 'postman-token: 8e87369d-e2e2-ab25-eadd-f40f0682e593' -d '{"name":"Roopesh", "no":"123123"}'

  1. Don't sent demoEntity=. Body should contains just json itself.
  2. Use -d key to send data. -F is for multipart body. It is a little bit different.

Upvotes: 5

Related Questions