Home  >  Forum  >  Web Services
Post New Query

javax.ws.rs.NotAcceptableException: No match for accept header


joined on
January 20,2015
Asked on March 10,2015
Hi Experts,

I am new to JAX-RS web service. I have created my service class as

    @POST
    @Path("/saveform")
    @Consumes("application/x-www-form-urlencoded")
    @Produces("application/json")
    public Response saveForm(@Form EmpForm form) {}

My client code is accessing using it as

        Entity<Form> entity = Entity.form(form);
        Response response = target.request(MediaType.APPLICATION_FORM_URLENCODED).post(entity);
        String value = response.readEntity(String.class);

I am getting error as below. Need help.


javax.ws.rs.NotAcceptableException: No match for accept header
at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:382)
at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:114)
at org.jboss.resteasy.core.registry.RootNode.match(RootNode.java:43)


joined on
March 14,2013
Replied on March 10,2015

You should use media type as APPLICATION_JSON in your client code.
as 
Response response = target.request(MediaType.APPLICATION_JSON).post(entity);

Find the link.

Write Answer









Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us