0

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.

Anoop M Maddasseri
  • 10,213
  • 3
  • 52
  • 73
JosephM
  • 2,935
  • 4
  • 18
  • 28

1 Answers1

2

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&param2=%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();
// ...

Courtsey

Community
  • 1
  • 1
Anoop M Maddasseri
  • 10,213
  • 3
  • 52
  • 73