It is necessary to get a token through the API of the custom site. Trying to use Apache HttpComponents, that's about what happened:
HttpClient httpclient = HttpClients.createDefault(); HttpPost httppost = new HttpPost("http://portal.com:8080/api/token/get?variant=4"); //Request parameters and other properties. List<NameValuePair> params = new ArrayList<NameValuePair>(2); params.add(new BasicNameValuePair("variant", "4")); httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); //Execute and get the response. HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); System.out.println("Responce: " + entity); System.out.println("Responce: " + response.getStatusLine() + " "+ entity.getContent()); if (entity != null) { InputStream instream = entity.getContent(); try { System.out.println("content^ " + instream); } finally { instream.close(); } } For example, in postman, I send a POST request to http://portal.com:8080/api/token/get with variant: 4 parameters, it forms such a request: http://portal.com:8080/ api / token / get? variant = 4 , and in response I receive a token of type af704d979924402e9509eafd415649c8 .
In Java, as I understand it, the server response is taken in this instream variable? When I try to display this variable, I’m writing "org.apache.http.conn.EofSensorInputStream@7ea9e1e2", but this is clearly not what I need.