Response res;
try {
res = httpPost(url, params.toArray(new PostParameter[params.size()]), true);
} catch (Exception e) {
throw new FitbitAPIException("Error creating food log entry: " + e, e);
}
if (res.getStatusCode() != HttpServletResponse.SC_CREATED) {
throw new FitbitAPIException("Error creating activity: " + res.getStatusCode());
}
try {
return new FoodLog(res.asJSONObject().getJSONObject("foodLog"));
} catch (JSONException e) {
throw new FitbitAPIException("Error creating food log entry: " + e, e);
}
}