title: Different behavior when sending POST Request through Java application and Chrome's POSTMAN Extension. How do I debug and find the mistake?
body: <p>I am making a POST Request to a server with <code>Content-Type</code> set to <code>application/x-www-form-urlencoded</code>. One of the query parameter has a value which contains <code>&amp;</code> in it. I replace the <code>&amp;</code> with <code>&amp;amp;</code> before sending the request.</p>
  
  <p>When I send this request using POSTMAN (Chrome Extension), the request goes fine and I receive the expected response. But when I send this request using a Java application, the server throws an error (unable to parse document). Here is the code that I'm using to send the request:</p>
  
  <pre><code>URL url = new URL(url); // url =&gt; "http://myserver.com/api/update"
  
  HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
  urlConnection.setConnectTimeout(60000);
  urlConnection.setReadTimeout(60000);
  urlConnection.setDoOutput(true);
  urlConnection.setRequestMethod("POST");
  urlConnection.setDoInput(true);
  urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  
  PrintWriter printWriter = new PrintWriter(urlConnection.getOutputStream());
  printWriter.print(params); // params =&gt; api_key=abcd123&amp;update_data_id=123&amp;update_data_value=Test&amp;amp;Value
  printWriter.flush();
  
  InputStream inputStream = urlConnection.getInputStream();
  String contentType = urlConnection.getContentType();
  
  FileUtil.closeWriter(printWriter);
  
  // Parse response ...
  </code></pre>
  
  <p>Here, the problem occurs in the parameter <code>update_data_value</code>. If I remove the <code>&amp;amp;</code>, the request goes fine from both, POSTMAN as well as my application. But when the <code>&amp;amp;</code> is present, only the request through POSTMAN works fine.</p>
  
  <p>What could be wrong ? </p>
  
  <p>Thanks a lot for your help!</p>