开发者

406 error in the Java code

开发者 https://www.devze.com 2023-01-15 21:27 出处:网络
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) {

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号