I'm trying to do a simple post request from a browser and 415 Unsupported Media
is show in browser's console, in the console it says too that the Type
is text/html
, maybe I'm mising something stupid here but seriously I'm doing post request from an android client and everything is find with the server side, so i guess (since I'm not familiar with js) it's a javascript problem I'm having here, here are the portions of interest of the code:
ajax (this function is called send
and it does some things before to create the json, that part it's ok and tested, the json is being genereated successfully):
$.ajax({
url: 'webresources/serverConfig/save/',
type: 'post',
dataType:'json',
data: jsonObj
});
how i call the javascript in the HTML form:
<form action="javascript:send()" method="post">
JAX-rs service:
@Path("serverConfig/")
public class ConfigurationSaverService {
@POST
@Path("save/")
@Consumes(MediaType.APPLICATION_JSON)
public void save(Configuration configuration){
//config stuffs here.
}
Edit:
due to @adrianplattner's answer, it's important to say that I'm using glassfish 4.0
, so i didn't need to add jersey's dependencies, I also try glashfish 3.1
and still get the same HTTP error.
EDIT 2:
Header:
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},