[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 730
  • Last Modified:

Https URL Connection Issue

Created URL object.
java.io.IOException: Server returned HTTP response code: 411 for URL: https://ABCD
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
      at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl.getInputStream(Unknown Source)
      at com.medco.cti.oracle.TEST.main(TEST.java:35)

Authenticator.setDefault(new MyAuthenticator());
			System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
			Class clsFactory = Class.forName("com.sun.net.ssl.internal.ssl.Provider");
 
			if ((clsFactory != null) && (Security.getProvider("SunJSSE") == null))
			{
			Security.addProvider((Provider)clsFactory.newInstance());
			}
 
			URL myURL = new URL("https://ABCD");
			System.out.println("Created URL object.");
			 // Install the custom authenticator
		    
			HttpsURLConnection connection = (HttpsURLConnection)myURL.openConnection();
			connection.setDoOutput(true);
			connection.setRequestMethod("POST");
			connection.setRequestProperty("Content-Type", "text/xml; charset=UTF-8"); 
			connection.setRequestProperty("Authorization", "Basic " + "Q1RJUFJPRDpQI0NUSTA5");
			connection.getInputStream();

Open in new window

0
Sujay1000
Asked:
Sujay1000
1 Solution
 
ahoffmannCommented:
411 Length Required

you need to pass a proper Content-Length: header also
0

Featured Post

Put Machine Learning to Work--Protect Your Clients

Machine learning means Smarter Cybersecurity™ Solutions.
As technology continues to advance, managing and analyzing massive data sets just can’t be accomplished by humans alone. It requires huge amounts of memory and storage, as well as high-speed processing of the cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now