title: Java: How to make API call with data?
body: <p>I want to make API call similar to below curl command:</p>
  
  <pre><code>curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer 
  1djCb/mXV+KtryMxr6i1bXw" 
  -d '{"operands":[]}' 
  https://ads.line.me/api/v1.0/authority_delegations/get
  </code></pre>
  
  <p><strong>What I am trying</strong></p>
  
  <pre><code>public void send_deligation_request(String details[]) throws Exception{
      System.out.println(Arrays.toString(details));
  
      URL line_api_url = new URL("https://ads.line.me/api/v1.0/authority_delegations/get");
      String payload = "{operands:[]}";
  
  
  
      HttpURLConnection linec = (HttpURLConnection)line_api_url.openConnection();
      linec.setDoInput(true);
      linec.setDoOutput(true);
      linec.setRequestMethod("POST");
      linec.setRequestProperty("Content-Type", "application/json");
      linec.setRequestProperty("Authorization", "Bearer "+access_token);
  
      OutputStreamWriter writer = new OutputStreamWriter(linec.getOutputStream(), "UTF-8");
      writer.write(payload);
  
  
      BufferedReader in = new BufferedReader(
                              new InputStreamReader(
                                      linec.getInputStream()));
      String inputLine;
  
      while ((inputLine = in.readLine()) != null) 
          System.out.println(inputLine);
      in.close();
  }
  </code></pre>
  
  <p>But I am getting below error:</p>
  
  <pre><code>[naofumi.haida@torchlight.co.jp, 5514]
  </code></pre>
  
  <blockquote>
  <pre><code>java.io.IOException: Server returned HTTP response code: 400 for URL: https://ads.line.me/api/v1.0/authority_delegations/get
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
    at AuthorityDelegation.send_deligation_request(AuthorityDelegation.java:66)
    at AuthorityDelegation.read_csv(AuthorityDelegation.java:36)
    at AuthorityDelegation.main(AuthorityDelegation.java:20)
  </code></pre>
  </blockquote>
  
  <p>Could somebody please help me?</p>