Created
March 20, 2025 12:19
-
-
Save sts-developer/ad98b0dd8634407464c9c0ca4a26865c to your computer and use it in GitHub Desktop.
Sample code for Java Form1099OID RequestPdfURLs 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/RequestPdfURLs"; | |
| 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\": \"dc888e87-ecf4-4d64-a13b-61458cb86763\",\r\n \"RecordIds\": [\r\n {\r\n \"RecordId\": \"868fb473-ea8d-4d9c-8c89-cfc13ed173c6\"\r\n }\r\n ],\r\n \"Customization\": {\r\n \"TINMaskType\": \"Both\"\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