Skip to content

Instantly share code, notes, and snippets.

@sts-developer
Created November 20, 2024 07:42
Show Gist options
  • Save sts-developer/ca365bacb7b52a8e9e8fce834f809565 to your computer and use it in GitHub Desktop.
Save sts-developer/ca365bacb7b52a8e9e8fce834f809565 to your computer and use it in GitHub Desktop.
Sample code for Java Form1099K List method
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Main {
public static void main(String[] args) throws Exception {
// Define the URL with the query parameter for BusinessId
String url = "https://testapi.taxbandits.com/v1.7.3/form1099K/List?BusinessId=bc89af91-c78b-4be8-927a-0c56ee02673c";
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
// Set the request method to GET
con.setRequestMethod("GET");
// Set request headers (e.g., Authorization, Content-Type)
con.setRequestProperty("Authorization", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJlYzE0NTIxYjMxNGY0N2RhOTc5ODMzYjVlZjkxNDU5ZSIsImV4cCI6MTcyMTIwNjk3NywiaWF0IjoxNzIxMjAzMzc3LCJpc3MiOiJodHRwczovL3Rlc3RvYXV0aC5leHByZXNzYXV0aC5uZXQvdjIvIiwic3ViIjoiYTQyMWE2MWUzOWUyY2U3ZSJ9.YjQP2gkoecj6tqyXJRcJ8LeeAsP0zwkQYk7iD0QHKW8");
con.setRequestProperty("Content-Type", "application/json");
// Get the response code and handle the response
int responseCode = con.getResponseCode();
BufferedReader in;
if (responseCode >= 200 && responseCode < 300) {
in = new BufferedReader(new InputStreamReader(con.getInputStream()));
} else {
in = new BufferedReader(new InputStreamReader(con.getErrorStream()));
}
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
// Print the response from the API
System.out.println(response.toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment