When making an https request I have the following exception:
javax.net.ssl.SSLException: Unsupported record version SSLv2Hello
public static void main(String[] args) throws Exception {
URL url = new URL("URL");
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
try {
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type","application/json; charset=UTF-8");
conn.setDoOutput(true);
conn.getResponseCode();
} catch (ProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
System.out.println(e);
}
conn.disconnect();
}
The exception happens in
} catch (IOException e) {
When trying to do
conn.getResponseCode ();