Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non 200 response #9

Closed
Naved81 opened this issue Apr 28, 2020 · 7 comments
Closed

Non 200 response #9

Naved81 opened this issue Apr 28, 2020 · 7 comments

Comments

@Naved81
Copy link

Naved81 commented Apr 28, 2020

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:

	Properties props = new Properties();
	props.setProperty("tda.client_id", "blah blah with @AMER.OAUTHAP at the end");
	props.setProperty("tda.token.refresh", "really long string");
	TdaClient tdaClient = new HttpTdaClient(props);

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.

@Denebulas
Copy link

It's exactly the same issue I opened 10 hours before you...

@studerw
Copy link
Owner

studerw commented May 2, 2020

I'm looking at this right now...

@studerw
Copy link
Owner

studerw commented May 3, 2020

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.

@Naved81
Copy link
Author

Naved81 commented May 3, 2020

I tried that already, same error message.

@studerw
Copy link
Owner

studerw commented May 4, 2020

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()));
	}
}

@studerw
Copy link
Owner

studerw commented May 4, 2020

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.

@Naved81
Copy link
Author

Naved81 commented May 4, 2020

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!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants