Closed Naved81 closed 4 years ago
It's exactly the same issue I opened 10 hours before you...
I'm looking at this right now...
I think your problem is the '@AMER.OAUTHAP' at the end of your client_id. Do NOT include that part. I only am using the client ID with is 32 alphanumeric digits (uppercase) long. Take out the @AMER.OAUTHAP and see if it works.
I tried that already, same error message.
This worked for me. It's a Junit test, but you can just run a main method instead using
public static void main...
package com.studerw.tda.demo;
import java.util.Properties;
import com.studerw.tda.client.HttpTdaClient;
import com.studerw.tda.client.TdaClient;
import com.studerw.tda.model.history.PriceHistory;
import org.junit.Test;
public class PriceHistoryTest {
@Test
public void testPriceHistory() {
Properties props = new Properties();
props.setProperty("tda.client_id", "D....19N"); //NO @AMER... junk here
props.setProperty("tda.token.refresh", "<ESCAPED_REFRESH_TOKEN>");
TdaClient tdaClient = new HttpTdaClient(props);
final PriceHistory priceHistory = tdaClient.priceHistory("FB");
priceHistory.getCandles().stream().forEach(candle ->
System.out.println(candle.toString()));
}
}
That worked for me. Can you try an easier test and just do something like:
Properties props = new Properties();
props.setProperty("tda.client_id", "D....19N"); //NO @AMER... junk here
props.setProperty("tda.token.refresh", "<ESCAPED_REFRESH_TOKEN>");
TdaClient client = new HttpTdaClient(props);
List<SecuritiesAccount> accounts = client.getAccounts(true, true);
accounts.forEach(account -> System.out.println(account.toString()));
It's possible you don't have the access to price history calls depending on your account level at TDA.
I created a fresh new repo in my IDE and did a git clone instead of just downloading the source and required libraries via pom.xml. Then I built a jar for the entire project and added that to the classpath of my project.
Did the trick.
Thanks for the code!
Hi there,
I got the response through https://api.tdameritrade.com/v1/oauth2/token successfully. I then copied the refresh token and client id (from app I created) into the properties as follows:
I keep getting this error for all API calls:
Exception in thread "main" java.lang.RuntimeException: Non 200 response: [404 - /v1/marketdata/FB/pricehistory] - https://apis.tdameritrade.com/v1/marketdata/FB/pricehistory at com.studerw.tda.client.HttpTdaClient.checkResponse(HttpTdaClient.java:622) at com.studerw.tda.client.HttpTdaClient.priceHistory(HttpTdaClient.java:165) at com.tdameritrade.PlayGround.play1(PlayGround.java:54) at com.tdameritrade.PlayGround.main(PlayGround.java:22)
Any ideas?
Thanks.