Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save sts-developer/426e4b44e52678ee7ae350088ccd6b76 to your computer and use it in GitHub Desktop.
Sample code for Java Form1099OID Delete 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 {
// URL of the API endpoint with query parameters
String url = "https://testapi.taxbandits.com/v1.7.3/Form1099OID/Delete?SubmissionId=9d71ae45-df5f-49f7-86f8-e88f54132fa1&RecordIds=01132f6d-ef4a-4014-817e-94a5a19bd52b,eb39714e-f653-4c4d-a53c-07f24f9a9dj5";
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
// Setting the request method to DELETE
con.setRequestMethod("DELETE");
// Adding headers
con.setRequestProperty("Authorization", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhM2VkMWE1ZTkwMWI0YmQzOTY5NTYwMTljYTRjMWZmOCIsImV4cCI6MTcyMzQ1Nzc1NiwiaWF0IjoxNzIzNDU0MTU2LCJpc3MiOiJodHRwczovL3Rlc3RvYXV0aC5leHByZXNzYXV0aC5uZXQvdjIvIiwic3ViIjoiOTc0YTFiZDU5Yjk3ZTE1YyJ9.DOdss97pIy6_rrS2IMDG5H8-sj0sg2cRF5upCVhBpBU");
// Since DELETE requests with a body are not common, ensure the server accepts this if needed
con.setDoOutput(true);
con.getOutputStream().write("".getBytes());
// 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