How to add a body to POST call in HTTPURLConnection in application/x-www-form-urlencoded format (JAVA)
JDK version is 1.8
Code tried:
String parameters = "key=value";
OutputStreamWriter wr = new OutputStreamWriter(con.getOutputStream());
wr.write(urlParameters);
The issue is fixed Used:
String parameters = "key=value";
byte[] parameters = urlParameters.getBytes(Charset.forName("UTF-8"));
OutputStreamWriter wr = new OutputStreamWriter(con.getOutputStream());
wr.write(urlParameters);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.