Reputation: 1526
This might be simple question. I tried googling but no luck. I have one DTO which is pass from client and consumed by the restful webservices. But getting this exception
Mapping exception to XML
avax.ws.rs.NotSupportedException: HTTP 415 Unsupported Media Type
and this is my restful method.
@PUT
@Path("microservice/persist")
@Consumes("application/json")
public long update(AsyncJobDTO asyncJobDTO){
//calling EJB and returing the value
}
this is my restful call
http://localhost:9090/nexterp-war/rest/api/Jobupdate/microservice/persist?format=format.json
Upvotes: 1
Views: 847
Reputation: 18782
It was because there was no accept header sent with the request. You need to send a Accepts
and Content-Type
headers with the client code.
Since your application accepted json, It should be
<code>'Accept': 'application/json'</code>
<code>'Content-Type': 'application/json'</code>
Similar posting in SO Http 415 Unsupported Media type error with JSON, Error 415 Unsupported Media Type: POST not reaching REST if JSON, but it does if XML
Upvotes: 1