我正在尝试向RunKeeper API发出此请求:
GET /user HTTP/1.1
主机:api.runkeeper.com
授权:Bearer xxxxxxxxxxxxxxxx
接受:application/vnd.com.runkeeper.User+json
我的代码:
private static final String BASEURL = "http://api.runkeeper.com";
public HttpResponse getUserInformation() throws IOException {
DefaultHttpClient client = new DefaultHttpClient();
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, "UTF_8");
HttpProtocolParams.setUseExpectContinue(params, false);
client.setParams(params);
HttpGet get = new HttpGet(BASEURL.concat("/user"));
String credentials = getCredentials();
get.addHeader("Authorization", "Basic " + credentials);
get.addHeader("Accept", "application/vnd.com.runkeeper.User+json");
return client.execute(get);
}
private String getCredentials() {
String source = "Authorization" + ":" + "Bearer " + getAccessToken();
String ret = Base64.encodeToString(source.getBytes(), Base64.URL_SAFE | Base64.NO_WRAP);
return ret;
}
但我不断得到:
HTTP 状态 500 - 服务器遇到内部错误 () 阻止它完成此请求。
我的错误是什么?