patriques82 / alphavantage4j

(Repository is not maintained anymore) A Java wrapper to get stock data and stock indicators from the Alpha Vantage API
https://www.alphavantage.co/
Apache License 2.0
124 stars 73 forks source link

Exception in new InputStreamReader #15

Closed aloorir closed 6 years ago

aloorir commented 6 years ago

I appreciate your help, I am getting an exception in following line:

I believe the error is in Class : AlphaVantageConnector.java, line 43.

InputStreamReader inputStream = new InputStreamReader(connection.getInputStream(),"UTF-8");

could you please give me some directions or guide to work with. I know basics but not an expert in java. Exception : Something went wrong

Thank you for your support!

patriques82 commented 6 years ago

Can you please provide the use case with some code, so the problem can be recreated.

aloorir commented 6 years ago

Sure, only things i changed from the original code are 1) url from "https" to "http" in AlphaVantageConnector.java 2) changed apikey to my personal key and increased timeout to 9000 in App.java[Usage].

then ran app.java which is usage from readme.md imported all the required classes and packages. compiled fine and got following exception :

Exception in thread "main" java.lang.IllegalStateException: Not a JSON Object: null at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:91) at co.alphavantage.output.JsonParser.parseJson(JsonParser.java:51) at co.alphavantage.output.timeseries.IntraDay.from(IntraDay.java:32) at co.alphavantage.TimeSeries.intraDay(TimeSeries.java:39) at App.main(App.java:21)

Just wanted to know if i am doing anything wrong. or need to include anything? if i use "https" should i include it in trusted website list?

Please let me know if you need more information.

aloorir commented 6 years ago

I fixed it thanks-

patriques82 commented 6 years ago

Just of curiosity, what was the problem? I assume it was the "http" instead of "https"