1

I am building project REST project with Spring Boot and i come across an issue of sending JSON from client to server. My Scenerio is i want to send json like this using postman REST client:

{
"test":"success"
}

And want to get this json using this method:

@RequestMapping(value = "/user", method = RequestMethod.POST)
    public Map<String, Object> postData(@RequestBody Map map){
        log.info("in test Connection method");
        return map;
    }

I am using above method but it is giving exception.

If it is not possible to process json data with @RequestBody with POST request then is there any other way to get json data with POST request and process that json data?

1
  • 1
    Add the stacktrace please. Commented Jun 3, 2015 at 8:20

1 Answer 1

1

I have just tested it here and it works fine.

You have to specify the Content-Type header in your POST request though, and set it to application/json. You can easily do this in Postman in the Headers tab.`

Without it you will most likely get an Internal Server Error (500) saying

Content type 'text/plain;charset=UTF-8' not supported

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.