-1
ULR url = new URL(urlString);

HttpURLConnection con = (HttpURLConnection) url.openConnection();

con.setRequestMethod("GET");

con.connect();

BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); 

String inputLine;

StringBuffer response = new StringBuffer();

while ((inputLine = in.readLine()) != null) 

{

response.append(inputLine);

}

in.close();

System.out.println(response.toString());
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • 405 status code means the request method is not allowed for a particular resource. Refer https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405 for more details. – sachin Jan 06 '21 at 07:33
  • Welcome to Stack Overflow. Please read [ask]. Just dumping code here isn't a good way to get help. Please provide some explanation of what you are trying to do and the _full_ error message, with line number and traceback. – ChrisGPT was on strike Jan 06 '21 at 14:43

1 Answers1

0

Please see HTTP status code: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

Your application should handle all HTTP standard Status Codes.

javadev
  • 688
  • 2
  • 6
  • 17