Reputation: 7021
Even if this error is known, I was not able to solve my issue!
The reset Service is declared in this code :
@POST
@Transactional
@Consumes(MediaType.APPLICATION_JSON)
@Path("/addProduct")
public void addProductToShoppingBag(JSONObject object) throws JSONException
and I'm sending a POST request using this javascript :
$.ajax({
header: 'application/json',
type: 'POST',
data: $.toJSON({
member_id: "1",
products_id: ["0","1"]
}),
url: url
}).done(success).error(failure);
and I'm getting the 415 - Unsupported Media Type error !!! any idea ?
Upvotes: 2
Views: 10104
Reputation: 171669
You want to set contentType
. Your header is not formatted properly
Switch:
header: 'application/json',
To
contentType: "application/json;charset=utf-8",
The proper header needs to include 'Content-Type'
in it and jQuery will take care of that for you
Upvotes: 9