I'm new to REST API and trying to work with the Get Quotes method in the Tradier API to retrieve market data about a specific company. The request is giving me back response 400 with my code below. Here is a link to the API documentation: https://documentation.tradier.com/brokerage-api/markets/get-quotes
try {
// MAKE REQUEST TO API
URL url = new URL("https://sandbox.tradier.com/v1/markets/quotes");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("Authorization", "Bearer <token>");
connection.setRequestMethod("GET");
connection.setRequestProperty("Accept", "application/json");
connection.addRequestProperty("symbols", "AAPL");
connection.connect();
// GET INPUT STREAM RESPONSE FROM REQUEST
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charset.forName("UTF-8")));
// TAKING BITS AND BYTES FROM BUFFERED READER TO BUILD IT INTO A STRING OBJECT
StringBuilder json = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
json.append(line);
}
JSONObject obj = new JSONObject(json.toString());
System.out.println(obj);
} catch (Exception ex) {
System.out.println(ex.getMessage());
}