rest - How to change Content-Type of GET-Request via firefox addon RESTClient -
i want send get-requests shall answered rest-api. java programm supports text/plain
, text/html
, text/xml
, application/json
using jax-rs reference implementation jersey.
to test different media types i'm using firefox addon restclient
. change media type shall adjust header name=content-type
, e.g. value=text/xml
.
but restclient returns text/html
no matter content-type
choose. way right modify returned result type is, uncomment html-section in code. text/plain
returned media type, still content-type
argument of restclient stays ignored.
i'm using resent version of restclient, right 2.0.3. can please me?
here java-code:
import javax.ws.rs.get; import javax.ws.rs.path; import javax.ws.rs.produces; import javax.ws.rs.core.mediatype; //sets path base url + /hello @path("/hello") public class restprovider { // method called if text_plain request @get @produces(mediatype.text_plain) public string sayplaintexthello() { return "hello little world"; } // method called if xml request @get @produces(mediatype.text_xml) public string sayxmlhello() { return "<?xml version=\"1.0\"?>" + "<hello> hello little world" + "</hello>"; } // method called if html request // uncommenting following 6 lines result in returning text/plain @get @produces(mediatype.text_html) public string sayhtmlhello() { return "<html> " + "<title>" + "hello world" + "</title>" + "<body><h1>" + "hello little world" + "</h1></body>" + "</html> "; } // method called if json requested @get @produces(mediatype.application_json) public string getjson(){ gson gsonobject = new gson(); return gsonobject.tojson(helloclass); } }
i think have specify accept
header media type want in addition content-type header states content type of request, not content type of response indeed set accept
header
so use accept header instead of content-type header
Comments
Post a Comment