I’m trying to make this request to the RunKeeper API:
GET /user HTTP/1.1
Host: api.runkeeper.com
Authorization: Bearer xxxxxxxxxxxxxxxx
Accept: application/vnd.com.runkeeper.User+json
My code:
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;
}
But I keep getting:
HTTP Status 500 – The server encountered an internal error () that prevented it from fulfilling this request.
What is my mistake here?
The URL you’re using is not correct. You’re supposed to request
/useronly.Add an accept header with this:
And are you sure you’re adding your credentials information correctly? The documentation states that the Authorization header should look like
Bearer xxxxxxxxxxxxxxxx, while yours isBasic .... Without looking into it further, perhaps this could be the solution:If it still doesn’t work properly, this page states that you should contact them to resolve the problem if you receive a Internal Server Error. I guess that could be done in this Google Group.