我有一个在Postman上运行良好的GET请求,但不适用于Eclipse。每次我得到这个回复:
HttpResponseProxy{HTTP/1.0 401 Unauthorized [Cache-Control: no-cache, Pragma: no-cache, Content-Type: application/json; charset=utf-8, Expires: -1, Server: , WWW-Authenticate: Raven, Date: Fri, 18 Mar 2016 09:47:13 GMT, Content-Length: 32, X-Cache: MISS from proxy, X-Cache-Lookup: MISS from proxy:3191, X-Cache: MISS from site.domain.com, X-Cache-Lookup: MISS from site.domain.com:8668, Via: 1.0 proxy:3191 (squid/2.6.STABLE21), 1.0 site.domain.com (squid/3.1.10), Connection: keep-alive]}
这就是我打电话的方式:
//String request; String key;
String signature = generateSignature(request, "HmacSHA256");
Resource resource = restClient.newBuilder()
.type(TypeFactory.defaultInstance()
.constructCollectionType(List.class, MyObject.class))
.timeout(30000)
.header("Authorization", "Raven " + signature)
.header("X-Raven-ApiKey", key)
.header("Content-Type", "application/json")
.param("SinceDate", sinceDate)
.param("Timestamp", String.valueOf(timestamp))
.build();
return resource.get();
出现此错误的可能原因是什么?
谢谢!
答案 0 :(得分:0)
@cdelmas你很严厉。我使用Base64对我的签名进行编码,最后添加了“\ r \ n”字符。我删除了它们并且有效。