• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpURLConnection - Server returned HTTP response code: 400

 
jebastan soundar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
I am getting this exception "java.io.IOException: Server returned HTTP response code: 400" while getting InputStream. Whereas, hitting the same URL in IExplorer gave the successful response. Please find below the code. Please help. Thanks.

code :

URL hostURL = new URL("http://www.domain.com/abc?paramters=values");
HttpURLConnection urlcon = (HttpURLConnection) hostURL.openConnection();
urlcon.setRequestMethod("GET");
urlcon.setDoInput(true);
//urlcon.connect(); --tried this one also...same exception
InputStream is=urlcon.getInputStream(); -- exception occurs at this line.


Please help me if anyone knows the answer..
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My browsers (both Firefox and Internet Explorer) get a 400 response for that URL too.
 
Rob Spoor
Sheriff
Pie
Posts: 20659
64
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If an IOException occurs while calling getInputStream(), you can call getErrorStream() and, if it does not return null, retrieve the actual error message from it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic