카테고리 없음

restful - 415 Unsupported Media Type 오류문제

[czar] 2016. 10. 26. 18:48

JSON 으로 호출하는데  415 Unsupported Media Type 오류가 발생한다.



@Path("/login")

@POST

@Consumes({ MediaType.APPLICATION_JSON }) // 수신

@Produces({ MediaType.APPLICATION_JSON }) // 응답

@Transactional

public Response login(@Context HttpServletRequest httpServletRequest, JSONObject jsonObject) {

System.out.println("jsonObject= = " + jsonObject);

int status = HttpServletResponse.SC_OK;

String authCredentials = httpServletRequest.getHeader(AUTHENTICATION_HEADER);


AuthenticationService authenticationService = new AuthenticationService();

boolean authenticationStatus = authenticationService.authenticate(authCredentials);

if (authenticationStatus) {

} else {

status = HttpServletResponse.SC_UNAUTHORIZED;

}

return Response.status(status).entity(jsonObject).build();

}



확인해야할 사항은


Content-Type: application/json to the "Headers":


headers 에 Content-Type이 application/json 으로 설정되어 있는지 확인한다.