title: How to post this http request in Java?
body: <p>In html it looks like that:</p>
  
  <pre><code>$.ajax({
     url : 'http://www.mclista.pl/json/daj_diax/',
     type : 'POST',
     data : {
         'id_serwera' : '39914',
         'csrf_mclista_token' : 'b7b96922dba267733168629d9f5ba6d7'
     },
     dataType : 'JSON',
     success : function(result) {
          if (result.status == 'ok') {
              $('#glosow_'+id).html(parseInt($('#glosow_'+id).html()) + 1);
           }else if(result.status == 'juz_glosowal')
                  alert('Możesz dać tylko jednego diax-a na jeden serwer.');
          }
      });
  </code></pre>
  
  <p>but how to send it from Java HttpURLConnection?
  My Code:</p>
  
  <pre><code>    String url="http://www.mclista.pl/json/daj_diax/";
      URL object=new URL(url);
  
      HttpURLConnection con = (HttpURLConnection) object.openConnection();
      con.setDoOutput(true);
      con.setDoInput(true);
      con.setRequestProperty("dataType", "JSON");
      con.setRequestMethod("POST");
      JSONObject cred = new JSONObject();
      cred.put("id_serwera", "41673").put("csrf_mclista_token", "587fb64c54defa881d293ee1aadb93fa");
      System.out.println(new String(cred.toString().getBytes(StandardCharsets.UTF_8)));
      OutputStream os = con.getOutputStream();
      os.write(cred.toString().getBytes("UTF-8"));
      os.close();
      BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), StandardCharsets.UTF_8));
       String inputLine;
       StringBuffer response = new StringBuffer();
       while ((inputLine = in.readLine()) != null) {
          response.append(inputLine);
       }
       in.close();
       System.out.println(response.toString());
  </code></pre>
  
  <p>It returns Disallowed Key Characters. I don't know what to do beacuse I tried almost everything (Remember that from html it is working)
  Cookies in success http request:
  <a href="https://i.stack.imgur.com/HQV2p.png" rel="nofollow noreferrer">COOKIES</a></p>