title: POST request works with POSTMAN but not in my Java application
body: <p>I brief description of what I'm doing, I'm automating creating incidents in ServiceNow using API. I have tested with POSTMAN first and it works fine. </p>
  
  <p>Now after I wrote the code, I try to post data, I got no respond from the server. what could be the problem?</p>
  
  <pre><code>    if (method.equals("POST") )
              {
                  url+= "api/now/table/incident";
              }
              else if (method.equals("GET")|| method.equals("PUT"))
              {
                  url+= "api/now/table/incident/" + incident.getSys_id();
              }
  
              URL request_url = new URL(url);
              CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
              connection = (HttpsURLConnection) request_url.openConnection();
  //            ((HttpsURLConnection) connection).setSSLSocketFactory(sslsocketfactory);
              if (method.equals("POST") || method.equals("PUT"))
              {
                  connection.setRequestProperty("Content-Type", "application/json");
              }
              else
              {
                  connection.setRequestProperty("Accept", "application/json");
              }
  
              connection.setRequestProperty("User-Agent", "Mozilla/5.0"); // this was suggested as solution, but doesn't work.
  
              connection.setRequestMethod(method);
              connection.setDoInput(true);
              connection.setDoOutput(true);
              connection.setUseCaches(false);
              connection.setRequestProperty("Authorization", "Basic "+encoded);
  
              if (method.equals("POST") || method.equals("PUT"))
              {
                  JSONObject json = new JSONObject();
  
                  json.put("short_description",incident.getShort_description());
                  json.put("description", incident.getDescription());
                  json.put("assignment_group",incident.getAssignment_group());
                  json.put("priority",incident.getPriority());
                  json.put("impact",incident.getImpact());
  
                  OutputStream os = connection.getOutputStream();
                  os.write(json.toJSONString().getBytes(StandardCharsets.UTF_8));
                  os.close();
              }
  
              // read the respond
              httpsCode = connection.getResponseCode();
              if (httpsCode == HttpsURLConnection.HTTP_OK || httpsCode == 201)
              {
                  //Read
                  BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
                  String lines = null;
                  StringBuilder stringBuilder = new StringBuilder();
                  while ((lines = bufferedReader.readLine()) != null)
                  {
                      stringBuilder.append(lines);
                  }
                  bufferedReader.close();
                  result = stringBuilder.toString();
                  JSONParser parser = new JSONParser();
                  JSONObject json = (JSONObject) parser.parse(result);
                  String incident_number = json.get("incident_number").toString();
                  String sys_id = json.get("sys_id").toString();
                  incident.setIncident_number(incident_number);
                  incident.setSys_id(sys_id);
  
                  return  null;
              }
  </code></pre>
  
  <p>the error is related to timeout, a posted solution suggested to set up the header to a browser type. but that's also didn't work.</p>