on 06-20-2017 6:45 PM
Hi... I deployed a code in HANA accessing a URL thru HTTPURLConnection
here is my code
URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); //add reuqest header con.setRequestMethod("POST"); con.setRequestProperty("User-Agent", "Mozilla/5.0 ( compatible ) "); con.setRequestProperty("Accept-Language", "en-US,en;q=0.5"); con.setDoInput(true); con.setRequestProperty("Accept","*/*"); con.setRequestProperty("content-type","application/x-www-form-urlencoded"); con.setRequestProperty("Content-length", "100"); con.setDoOutput(true); con.setUseCaches(false); con.setReadTimeout(15*1000); con.setInstanceFollowRedirects(true); con.setFollowRedirects(true); String urlParameters = "sn=C02G8416DRJM&cn=&locale=&caller=&num=12345"; // Send post request con.setDoOutput(true); DataOutputStream wr = new DataOutputStream(con.getOutputStream()); wr.writeBytes(urlParameters); wr.flush(); wr.close(); int responseCode = con.getResponseCode(); System.out.println("\nSending 'POST' request to URL : " + url); System.out.println("Post parameters : " + urlParameters); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); System.out.println("Response Code : " + responseCode);
error:
java.io.IOException: Server returned HTTP response code: 502 for URL: (URL link)
can someone please tel me where am i missing? Thanks
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.