Im working with java spring mvc and angular js.
I created a rest service:
@RestController
public class UserApiController {
@Autowired
private UserService userService;
@RequestMapping(value = "/users/createUser", method = RequestMethod.POST)
public @ResponseBody void addUser(@RequestBody UserRequestDTO newUser) {
userService.addUser(newUser);
}
And my angular controller like this:
var newUser = { surname : "orozco", name: "daniel", password: "pepe", email:"dani@dani.com" };
$http.post(getCompletePath("users/createUser"), JSON.stringify(newUser))
.success(function () {
alert("ok");
}).error(function () {
});
It return the following error: 415 (Unsupported Media Type).
If I send a string o no parameters, it works. So, the problem is in the parameters
Aucun commentaire:
Enregistrer un commentaire