Skip to content
Advertisement

Tag: httpurlconnection

How to set proxy header in HttpURLConnection

I am trying to build an HTTP request to be sent via a proxy that accepts a proxy header. I am trying to find a way to set that, but couldn’t see it. Below is the curl command which I need to convert to the Java code. curl -i -u user:pwd -k GET –http1.1 –proxy-insecure https://localhost:8443 –proxy-header “X-Connect-Client-Id: abcde” https://target_host/api

How to solve KeyError: 400 Bad Request

I have a server to which I want to send post requests in the form of json in Java. But after sending, it gives the answer: “KeyError: 400 Bad Request: The browser (or proxy) send a request that this server could not understand.”. No matter how I change the data, it still gives this error, and the sent requests do

Exception : java.lang.IllegalStateException: Already connected

Hi I’m trying to use HttpURLConnection to send some POST data to a server using the HttpURLConnection class as shown below but it is throwing “java.lang.IllegalStateException: Already connected.” at the code – conn.setRequestProperty(eachEntry.getKey(), eachEntry.getValue()); in the below code. Can any one pls suggest what mistake I am doing here. Also the similar .setRequestPorperty, I am using in other places and

Sending Image files and Text from android app java HttpURLConnection multipart form-data

Hi I am trying to upload a file and a text, using multipart form-data HttpURLConnection java, sample of code below: additional details: I/File:: /storage/emulated/0/DCIM/100ANDRO/DSC_0117.JPG I/Api response: 400, Bad Request Note: I tested server from postman, and it working with no issues with Postman, the files where uploaded successful to the server from postman. This link is another post of a sample

Advertisement