title: curl command equivalent in java
body: <p>Here is my curl command:</p>
  
  <pre><code>curl https://login.xyz.com/v1/oauth/token -H "Accept:
  application/json" --data 'client_id=client_id' --data
  'client_secret=client_secret' --data 'redirect_uri=redirect_uri'
  --data 'code=code'
  </code></pre>
  
  <p>I'm trying to post that in java. Here is what i was trying to do:</p>
  
  <pre><code>String resourceUrl = "https://login.xyz.com/v1/oauth/token?client_id=&lt;client.id&gt;&amp;client_secret=&lt;client.secret&gt;&amp;redirect_uri=https://login.xyz.com/user/login&amp;code=&lt;code&gt;";
  HttpURLConnection httpcon = (HttpURLConnection) ((new URL(resourceUrl).openConnection()));
  httpcon.setDoOutput(true);
  httpcon.setRequestProperty("Content-Type", "application/json");
  httpcon.setRequestProperty("Accept", "application/json");
  httpcon.setRequestMethod("POST");
  httpcon.connect();      
  System.out.println(httpcon.getHeaderField(0));
  </code></pre>
  
  <p>But I'm getting HTTP/1.1 500 Internal Server Error</p>