10-07-2014 08:59
10-07-2014 08:59
I am getting following exception from the fitbit jar I am using
com.fitbit.api.FitbitAPIException: 400: The request was invalid. An accompanying error message will explain why.
{"errors":[{"errorType":"request","fieldName":"n/a","message":"This request should use https protocol."}],"success":false}
at com.fitbit.api.client.http.HttpClient.httpRequest(HttpClient.java:460)
at com.fitbit.api.client.http.HttpClient.get(HttpClient.java:398)
at com.fitbit.api.client.FitbitApiClientAgent.httpGet(FitbitApiClientAgent.java:2784)
at com.fitbit.api.client.FitbitApiClientAgent.httpGet(FitbitApiClientAgent.java:2734)
at com.fitbit.api.client.FitbitApiClientAgent.getDevices(FitbitApiClientAgent.java:1159)
10-13-2014 12:42
10-13-2014 12:42
The exception means that the endpoint that you're using has to work through https protocol.
Please beware that starting from Nov 3 2014 all API endpoints will require HTTPS protocol.
So please make sure that you update your code by that time.
If you use Fitbit4j library the option you have is either fork from this project and build jar that uses HTTPS only.
Or you can only override the only single class and have it use https instead of http and put it inside your project with the same path as it is inside fitbit4j. The class you need to modify is FitbitApiClientAgent as far as I remember, you just need to update the getApiBaseUrl() to look like that:
public String getApiBaseUrl() {
return getApiBaseSecuredUrl();
}