I am sending POST from JQuery using some data, but thru my Javascript I get:
400 Bad Request error and REST not firing
Trying it from Poster I get the following:
HTTP Status 415 - Unsupported Media Type.The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.
Here is my JQuery:
function doUpdate(path, rdf)
{
var encodedRdf = base64_encode(rdf);
var data = {"path": path, "rdf": encodedRdf};
var sUrl = "http://localhost:8080/browsing/services/RDF/update";
$.ajax({
type: "POST",
url: sUrl,
contentType: "application/json",
data: data,
dataType: "json",
async: false,
success: function parse(resp, status, xhr) {
$("#message").html("STATUS: " + xhr.status + " " + xhr.statusText + "\n" + resp);
$("#message").hide();
$("#login_message").html("<font color='green'><b>Record succesfully updated</b></font>d");
},
error: function(resp, status, xhr){
$("#message").html("ERROR: " + resp.status + " " + resp.statusText + "\n" + xhr);
$("#message").show();
}
});
}
Here is my REST Resource:
@POST
@XmlElement(name = "data")
@Path("/update")
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Produces(MediaType.APPLICATION_JSON)
public void update(Data data) {
...
}
Here is my Data Object:
@XmlRootElement
public class Data implements Serializable {
private String path;
private String rdf;
/**
* @return the path
*/
public String getPath() {
return path;
}
/**
* @param path the path to set
*/
public void setPath(String path) {
this.path = path;
}
/**
* @return the rdf
*/
public String getRdf() {
return rdf;
}
/**
* @param rdf the rdf to set
*/
public void setRdf(String rdf) {
this.rdf = rdf;
}
Any one can tell me where is the problem please?
Thanks,