Skip to content

Instantly share code, notes, and snippets.

@sts-developer
Created March 20, 2025 12:25
Show Gist options
  • Select an option

  • Save sts-developer/bf07f43e6bd6c05978c5bc6bbd9bdcd8 to your computer and use it in GitHub Desktop.

Select an option

Save sts-developer/bf07f43e6bd6c05978c5bc6bbd9bdcd8 to your computer and use it in GitHub Desktop.
Sample code for Java Form1099OID Validate method
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) throws Exception {
// Base URL
String baseUrl = "https://testapi.taxbandits.com/v1.7.3/Form1099OID/Validate";
// Query parameters
Map<String, String> queryParams = new HashMap<>();
queryParams.put("SubmissionId", "42c589e6-f824-4a0c-afca-8f592c62b2fd");
queryParams.put("RecordIds", "7c1654e0-b0a0-4719-b5af-76596d79ca25");
// Build the full URL with query parameters
StringBuilder urlBuilder = new StringBuilder(baseUrl);
urlBuilder.append("?");
for (Map.Entry<String, String> entry : queryParams.entrySet()) {
urlBuilder.append(URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8));
urlBuilder.append("=");
urlBuilder.append(URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8));
urlBuilder.append("&");
}
// Remove the trailing '&'
urlBuilder.deleteCharAt(urlBuilder.length() - 1);
String url = urlBuilder.toString();
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
// Setting the request method to GET
con.setRequestMethod("GET");
// Adding headers
con.setRequestProperty("Authorization", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJlYzE0NTIxYjMxNGY0N2RhOTc5ODMzYjVlZjkxNDU5ZSIsImV4cCI6MTcyMzQ1MzY0OSwiaWF0IjoxNzIzNDUwMDQ5LCJpc3MiOiJodHRwczovL3Rlc3RvYXV0aC5leHByZXNzYXV0aC5uZXQvdjIvIiwic3ViIjoiYTQyMWE2MWUzOWUyY2U3ZSJ9.VM4jhtJ6xM3Nbc9JJDLxwESDj6wP7LCY2U1E51o9fbE");
// Since this is a GET request, no need to setDoOutput(true)
// Reading the response
BufferedReader in;
int responseCode = con.getResponseCode();
if (responseCode >= 200 && responseCode < 300) {
in = new BufferedReader(new InputStreamReader(con.getInputStream()));
} else {
in = new BufferedReader(new InputStreamReader(con.getErrorStream()));
}
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
// Printing the full response
System.out.println(response.toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment