Posting xml to a spring REST endpoint is not getting unmarshalled into the relevant Java object?

You might try change the @RequestMapping on the class from.

You might try change the @RequestMapping on the class from: @RequestMapping("/users") to: @RequestMapping("/users/*") And then change the method declaration to: @RequestMaqpping(method=RequestMethod. POST) @ResponseBody public void create(@RequestBody User user) { The url would then become: localhost:8080/rest/users/create, because spring will take the final portion of the url from the method name.

I get the 400 error. The request sent by the client was syntactically incorrect (). – Uma Shankar Mar 15 at 5:33 Try giving the create method an empty parameter list.

This will help you to see if the problem is with the url mapping, or with the @RequestBody annotation. I'm guessing its with @RequestBody since the url mapping looks fine, but its good to check. Then you can write a junit test to be sure the unmarshaller can parse your XML.

– Kevin Mar 15 at 14:40.

Try change the curl line to curl -X POST -HContent-type:application/xml -HAccept:application/xml \ --data '1email@email. Comfirst_namelast_name' \ localhost:8080/Test/rest/users/new Their were quotation marks in the XML which may have interfered with the input.

Thanks David. The reserved characters in the Curl language are: {, }, \, and | (developers.curl. Com/userdocs/docs/en/dguide/basic-syntax.

Html) I removed the Sorry it didn't help – David Rabinowitz Mar 14 at 11:47.

I was running across the same issue as well. Here's what my Controller method looked like: @RequestMapping(method=RequestMethod. POST, value="/users/create", headers="Accept=application/xml") public @ResponseBody User createUser(@RequestBody User user) { return user; } Basically, I was just going to return the user object as a proof-of-concept to make sure that my POST was working correctly.

However, I kept running into the 'syntactically incorrect' message. Once I actually updated my code to retrieve a valid User object like so: @RequestMapping(method=RequestMethod. POST, value="/users/create", headers="Accept=application/xml") public @ResponseBody User createUser(@RequestBody User user) { userService.

CreateUser(user); // do work User newUser = userService. GetUserById(user.getId()); return newUser; } it started working correctly. I tested my REST API using the following CURL command: curl -X POST -HContent-type:application/xml -HAccept:application/xml --data "Quinnsterpassword" http://localhost:8080/api/users/create Using a different API to list users, I was able to verify that my new user was created properly.

Again, not sure if this is the exact same problem you're having, but this solved it for me. Thanks, Quinn.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions