Forums Register Login

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

+Pie Number of slices to send: Send
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()));
+Pie Number of slices to send: Send
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.
Listen. That's my theme music. That's how I know I'm a super hero. That, and this tiny ad told me:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 22028 times.
Similar Threads
HttpURLConnection - Server returned HTTP response code: 400
Unable to access URL using HttpURLConnection
Error 405 with HttpUrlConnection when request web service
Server returned HTTP response code: 505
Rest Client
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 00:09:38.