i am writing java code for calling REST API's .
i am getting 406 error with the following code
public List<BlogBean> view_blogsbytagXml(String tag,String limit) {
final String VIEW_BLOGSBYTAG1="api/blogs/tag/"+tag+".xml?limit="+limit+"";
return webResource.path(VIEW_BLOGSBYTAG1).header(ConfigurationUtil.AUTHENTICATION_HEADER, authentication)
.accept(MediaType.APPLICATION_XML_TYPE).get(new GenericType<List<BlogBean>>(){});
}
The connections are , private final WebResource webResource; private final String authentication;
authentication = ConfigurationUtil.getAuthenticationKey();
ClientConfig config = new DefaultClientConfig();
Cli开发者_如何学JAVAent client = Client.create(config);
webResource = client.resource(ConfigurationUtil.BaseURI);
i am getting 406 error in the above code
but when i gave the String as
final String VIEW_BLOGSBYTAG="api/blogs/tag/"+tag+".xml";
it doesnt show the error for me ..
Code 406 is HTTP status. Server maybe wants send data in other MediaType than MediaType.APPLICATION_XML_TYPE.
精彩评论