Reputation: 2935
Doing GET
request with URLConnection
. code is here
java.net.URL url = new java.net.URL(requestUrl);
URLConnection urlConnection = url.openConnection();
is = new BufferedInputStream(urlConnection.getInputStream());
getting java.io.FileNotFoundException
whereas requested url is correct. i think it may be https ssl certificate issue. if anyone else got this issue and resolved please update.
Upvotes: 0
Views: 833
Reputation: 10529
Encode your parameter to create an URL for request.Unsupported character in parameter value may cause to exceptions it can be a white space also.
String url = "http://url.com";
String charset = "UTF-8"; // Or in Java 7 and later, use the constant: java.nio.charset.StandardCharsets.UTF_8.name()
String param1 = "value1";
String param2 = "value2";
// ...
String query = String.format("param1=%s¶m2=%s",
URLEncoder.encode(param1, charset),
URLEncoder.encode(param2, charset));
URLConnection connection = new URL(url + "?" + query).openConnection();
connection.setRequestProperty("Accept-Charset", charset);
InputStream response = connection.getInputStream();
// ...
Upvotes: 2