I sent a HTTP POST request using HttpURLConnection. Could someone tell me how to format the array parameters and send them. Here are the request Body parameters in JSON.
{
  "data": [
    {
      "type": "enrolled-courses",
      "id": "ea210647-aa59-49c1-85d1-5cae0ea6eed0"
    }
  ]
}
Currently this is my Code.
 private void sendPost() throws Exception {
             URL url = new URL("my_url");
                Map<String,Object> params = new LinkedHashMap<>();
                params.put("type", "courses");
                params.put("id", "19cfa424-b215-4c39-ac13-0491f1a5415d");           
                StringBuilder postData = new StringBuilder();
                for (Map.Entry<String,Object> param : params.entrySet()) {
                    if (postData.length() != 0) postData.append('&');
                    postData.append(URLEncoder.encode(param.getKey(), "UTF-8"));
                    postData.append('=');
                    postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));
                }
                byte[] postDataBytes = postData.toString().getBytes("UTF-8");
                HttpURLConnection conn = (HttpURLConnection)url.openConnection();
                conn.setRequestMethod("POST");
                conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
                conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
                conn.setDoOutput(true);
                conn.getOutputStream().write(postDataBytes);
                Reader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
                for (int c; (c = in.read()) >= 0;)
                    System.out.print((char)c);
            }
The response Code is 204 which means no content. I would appreciate any help.
 
    