Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- URL obj = new URL("URL zum Ziel");
- HttpURLConnection con = (HttpURLConnection)obj.openConnection();
- con.setDoOutput(true);
- con.setRequestMethod("POST");
- con.setRequestProperty("User-Agent", "Java Webhook Class.");
- con.setRequestProperty("Content-Type", "application/json");
- con.setRequestProperty("Content-Length", "Mein Body ist hier".getBytes().length);
- con.setRequestProperty("Accept", "application/json");
- //Versuch 1
- con.getOutputStream().write("Mein Body ist hier".getBytes());
- con.getOutputStream().close();
- //Versuch 2
- OutputStreamWriter os = new OutputStreamWriter(con.getOutputStream());
- os.write("Mein Body ist hier".getBytes());
- os.close();
Advertisement
Add Comment
Please, Sign In to add comment