Hi, I am trying to publish json data for Restful WS implemented using Jersey. I am sending data via jquery-ajax. Why am I getting an unsupported HTTP Status-415 content type? Thank.
Click here to see a screenshot of the firebug description
@Path("/newentry")
public class NewEntry {
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response newEntry(String data) {
}
}
$.ajax({
url: "http://localhost:8080/FirstRestWebService/rest/newentry",
type: "post",
data: formToJSON(),
dataType : "json",
success: function(data){
alert("success");
},
error:function(jqXHR, textStatus, errorThrown) {
alert("failure");
}
});
function formToJSON() {
return JSON.stringify({
"name": $("input#emp_name").val(),
...
"username": $('input#username').val(),
"password": $('input#password').val()
});
Click here to view a screenshot of the firebug description.
I was able to successfully test WS using the Jersey Client . What is wrong with the above AJAX call? Thank.
source
share