I need to send data to the mail (more precisely to the server, and there the server to the mail) POST request with parameters. Please help me how to do this, the error code does not issue, I can not understand what exactly is wrong. No response from the server is needed, just send the data.
Here is the code:
@Override protected Void doInBackground(String... params) { try { String paramss = "name=" + params[0] + "@number=" + params[1]; URL url = new URL("http://177.177.177.237:86/send/"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Length", paramss); connection.connect(); Log.e("TAG", "Opa " + connection.getResponseCode()); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
As a result, the code does not issue errors, nothing comes to the mail, the code 400 in the Opa logs
Another option was to enter the parameters in the URL, but also did not help
URL url = new URL("http://177.127.177.237:86/send/name=" + params[0] + "@number=" + params[1]);
connection.setRequestProperty("Content-Length", paramss);
? - s8am