I am building my first API. The GET request works, but i am stuck at a POST request with error 415 Unsupported mediatype. After some searching and rewriting code, it still fails. Does someone see why? The parameter values are :
-String userName
-String password
-String phone
-String email
-List roles
CODE: UserResource:
@RolesAllowed("OWNER")
@POST
@Consumes(MediaType.APPLICATION_JSON)
public void create(@PathParam( "userName" ) String userName,@PathParam( "password" ) String password,@PathParam( "phone" ) String phone,@PathParam( "email" ) String email,@PathParam( "roles" ) List<String> roles)
{
User user = new User();
user.setName(userName);
user.setPassword(password);
user.setPhone(phone);
user.setEmail(email);
user.setRoles(roles);
userService.createUser(user);
}
UserService:
public void createUser(User user){
userDAO.create(user);
}
UserDAO:
public void create( User user )
{
save( user );
}
the POST request:
localhost:8080/User/?userName=Daniel&password=test&phone=0634554567&email=daniel@email.com&roles=["OWNER"]