Home  >  Forum  >  Web Services
Post New Query

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

Asked on March 10, 2015
Hi Experts,

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

    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)

Replied on March 10, 2015
You should use media type as APPLICATION_JSON in your client code.
Response response = target.request(MediaType.APPLICATION_JSON).post(entity);

Find the link.

Write Answer

©2021 concretepage.com | Privacy Policy | Contact Us