Created
March 20, 2025 12:29
-
-
Save sts-developer/2cbe34d3602f32a6c1ccc83d7e16bae8 to your computer and use it in GitHub Desktop.
Sample code for Java Form1099OID GetbyRecordIds 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.BufferedReader; | |
| import java.io.OutputStream; | |
| 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/GetbyRecordIds"; | |
| 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"); | |
| // Enable input/output streams | |
| con.setDoOutput(true); | |
| // Create JSON body | |
| String jsonInputString = "{\r\n \"RecordIds\": [\r\n {\r\n \"RecordId\": \"02d1de6d-c04e-48f4-a149-eb7a85af136c\"\r\n }\r\n ]\r\n}"; | |
| // Write JSON body to the output stream | |
| try (OutputStream os = con.getOutputStream()) { | |
| byte[] input = jsonInputString.getBytes("utf-8"); | |
| os.write(input, 0, input.length); | |
| } | |
| // Read 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(); | |
| // Print the response | |
| System.out.println(response.toString()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment