i want to change the request methodo from GET to POST. This is my code:
HttpURLConnection connection = null;
URL url = new URL("https://accounts.google.com/o/oauth2/token");
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setUseCaches (false);
connection.setDoInput(true);
connection.setDoOutput(true);
But as u see in this image while debugging the methodo of the request doesn't change:

That's just an implementation detail. The HttpsURLConnectionImpl object has a reference to a delegate, and sets that delegate's request method. If you expand the delegate field and check its method field, you'll see POST.
If you follow through with the code, you'll also see it attempts to send a POST request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With