iamtrask / quandl-java

This is a java api for the quandl dataservice.
GNU General Public License v2.0
16 stars 11 forks source link

getDatasetWithParams org.apache.http.client.HttpResponseException #5

Open giest4life opened 10 years ago

giest4life commented 10 years ago

The following use of the getDatasetWithParams(params) method gave me an org.apache.http.client.HttpResponseException

QuandlConnection q = new QuandlConnection("mytoken")

HashMap<String, String> params = new HashMap<String, String>(); params.put("trim_start","2012-09-30"); params.put("code","GDP"); params.put("source_code","FRED"); QDataset data3 = q.getDatasetWithParams(params);

It is because the getDataSetWithParams(prams) method is truncating the last character in the auth_token. Here is the output for the getDataSetWithParams(params) method: Executing request: http://www.quandl.com/api/v1/datasets/FRED/GDP.json?trim_start=2012-09-30&auth_token=mytoke

A fix for this is to change the return statement in the getDataSetWithParams(prams) method in QuandlConnection class to the following: return new QDataset(curl(baseUrl + params.get("source_code") + "/" + params.get("code") + ".json" + paramString.substring(0, paramString.length() - 1)), "json"); More specifcially, changing the paramString.substring(0, paramString.length() - 2) to paramString.substring(0, paramString.length() - 1)

Note: Keep in mind that this error doesn't show up until you exhaust your daily quota of 50 free queries.