This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes java.io.IOException: Server returned HTTP response code: 400 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "java.io.IOException: Server returned HTTP response code: 400" Watch "java.io.IOException: Server returned HTTP response code: 400" New topic
Author

java.io.IOException: Server returned HTTP response code: 400

Hassam Khan
Greenhorn

Joined: Dec 21, 2006
Posts: 3
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.

Regards,
Hassam


URL hostURL = new URL("https://www.domain.com/abc?paramters=values");

HttpURLConnection urlcon = (HttpURLConnection) hostURL.openConnection();
urlcon.setRequestMethod("GET");
urlcon.setDoOutput(true);
urlcon.setDoInput(true);
urlcon.setUseCaches(false);

BufferedReader inputdata = new BufferedReader(new InputStreamReader(urlcon.getInputStream()));
Van Glass
Ranch Hand

Joined: Nov 18, 2000
Posts: 110
400 error code means "bad request". It may be that the url only accepts POST requests or there is something that is not properly URL encoded in your parameters.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.io.IOException: Server returned HTTP response code: 400
 
Similar Threads
Rest Client
Error 405 with HttpUrlConnection when request web service
HttpURLConnection - Server returned HTTP response code: 400
Server returned HTTP response code: 505
Unable to access URL using HttpURLConnection