Hello, Query: How to ensure server sends JSON Media, when server is set with both Application_XML and Application_JSON Media Types (Produces annotation).
I am executing a RESTEasy POC. I updated the server to accept and respond with both XML and JSON Media type. @POST @Path("/getData/") @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public RestReqRes getData(Data request); In the client code, I have done this: this.clientService = ProxyFactory.create(clientService.class, baseURL, getExecutor()); and Override execute() method in ApacheHttpClient4Executor. request.accept(MediaType.APPLICATION_JSON); request.body("application/json", request.getBody()); return super.execute(request); When the client is used to POST the Request, like clientService.getData(new Data()); I found the below The accept header in the Request is updated with "application/xml". This happens due to org.jboss.resteasy.client.core.marshallers.ClientMarshallerFactory.createMarshaller() method, which calls org.jboss.resteasy.util.getConsumes() method. The getConsumes() method returns the consume.value()[0] media type which is 'application/xml' in this case. When request.accept(MediaType.APPLICATION_JSON); is executed the accept header in the request is updated with 'application/xml, application/json' Due to this the server always responds with xml format. Is there anyway I can override this so that the server responds JSON media as per the request. Thank you, Malaya Kishore ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412 _______________________________________________ Resteasy-users mailing list Resteasy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/resteasy-users