WebApi Get方法JAVA

时间:2016-11-24 18:53:03

标签: java asp.net-web-api

我想在Java中使用restapi并继续收到错误401.

如果我删除了webapi中的授权,我没有任何问题,只是在启用授权并且我必须在标题中传递令牌时才会出现问题。我需要在标题

中传递令牌

这就是我所拥有的

public getRestTest() throws IOException{

   final List<Object> providers = new ArrayList<>();
   providers.add(new JacksonJaxbJsonProvider());
   WebClient client = WebClient.create("http://resturl/api/controller/", providers);

   String token = Authenticate(); //I get the Authorization token as string in here
   client.header("Token", token);   

   Response response = client.get(); //error 401 in here

   return null;
 }

0 个答案:

没有答案
相关问题