Reputation: 3494
I need to know how to POST
to a HTTPS
web service. I went through the tutorial but it didn't help because it is too old.
Can anyone please help me out by giving me a good tutorial or some sample code to start with?
Upvotes: 1
Views: 1060
Reputation: 35341
Something like this:
URL url = new URL("https://...");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
//write the request body
OutputStream requestBody = connection.getOutputStream();
...
requestBody.flush();
//send the request and get the response body
InputStream responseBody = connection.getInputStream();
...
Upvotes: 0