I am having some problems sending a POST request in java to a local server. I tested this local server with Postman and it is indeed working as it should. Sadly when i try sending the POST requst in java, everything goes as it should with 200 OK code, BUT there is nothing in the body. This is my code:
public static void request1() throws MalformedURLException, ProtocolException, IOException {                
    URL url = new URL("http://192.168.1.200");
    HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
    httpCon.setDoOutput(true);
    httpCon.setRequestMethod("POST");
    OutputStream os = httpCon.getOutputStream();
    OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8");       
    osw.write("Just Some Text");
    osw.flush();
    osw.close();
    os.close();  //don't forget to close the OutputStream
    httpCon.connect();  
    System.out.println(httpCon.getResponseCode());
    System.out.println(httpCon.getResponseMessage());
}
EDIT: i see some of you said that this is a duplicate and gave me another link where it is supposed to be solved. Sadly i tried the code from that link and it is not working. Server simply says that the request has no body.
 
     
    