I'm using an HttpsURLConnection to connect to an application. Everything is fine until I'm trying to use parameters (like username and password) in the request due to the fact that on server side null values are mapped to parameters.
HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
connection.addRequestProperty("password", "xxxx");
connection.addRequestProperty("username", "aaaaaa");
connection.addRequestProperty("eventId","btnLogin");
connection.setRequestMethod("POST"); //$NON-NLS-1$
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty( "Accept", "*/*" );
BufferedReader in = new BufferedReader(
new InputStreamReader(
connection.getInputStream()));
String decodedString;
while ((decodedString = in.readLine()) != null) {
System.out.println(decodedString);
}
I mention that HttpsURLConnection works and the initial login page is retrieved via HttpsUrlConnection.
How can I send successfully the parameters on the server side via a POST request?