Created
March 20, 2025 12:13
-
-
Save sts-developer/9fc39f90766392fe656477ceef5574dd to your computer and use it in GitHub Desktop.
Sample code for Java Form1099OID Transmit method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.OutputStream; | |
| 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 { | |
| // URL of the API endpoint | |
| String url = "https://testapi.taxbandits.com/v1.7.3/Form1099OID/Transmit"; | |
| URL obj = new URL(url); | |
| HttpURLConnection con = (HttpURLConnection) obj.openConnection(); | |
| // Setting the request method to POST | |
| con.setRequestMethod("POST"); | |
| // Adding headers | |
| con.setRequestProperty("Authorization", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhM2VkMWE1ZTkwMWI0YmQzOTY5NTYwMTljYTRjMWZmOCIsImV4cCI6MTcyMzQ1Nzc1NiwiaWF0IjoxNzIzNDU0MTU2LCJpc3MiOiJodHRwczovL3Rlc3RvYXV0aC5leHByZXNzYXV0aC5uZXQvdjIvIiwic3ViIjoiOTc0YTFiZDU5Yjk3ZTE1YyJ9.DOdss97pIy6_rrS2IMDG5H8-sj0sg2cRF5upCVhBpBU"); | |
| con.setRequestProperty("Content-Type", "application/json"); | |
| // Setting doOutput to true to send a request body | |
| con.setDoOutput(true); | |
| // Creating JSON body | |
| String jsonInputString = "{\r\n \"SubmissionId\": \"efacde0b-93e4-4327-84f5-f003b14fdc47\",\r\n \"RecordIds\": [\r\n \"7629fc38-5a6f-4b51-842e-b3058bc5a94c\"\r\n ]\r\n}"; | |
| // Writing the JSON body to the output stream | |
| try (OutputStream os = con.getOutputStream()) { | |
| byte[] input = jsonInputString.getBytes("utf-8"); | |
| os.write(input, 0, input.length); | |
| } | |
| // Reading 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; | |
| 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