title: How to pass an array to POST API?
body: <p>In my Android application, I need to send an array as body (payload information) to a POST url.</p>
  
  <p>In body, there are two params:</p>
  
  <pre><code>1. "env" : "dev"  
  2. "dNumber" : tn("+1232323"); // here I need to send an array.
  </code></pre>
  
  <p>Edited question: I need to send phone as an array like ["123131","4545545"]</p>
  
  <p>I pass the array as created a JSON array and convert to string and passed.</p>
  
  <pre><code>private String tn(String tn) {
      String json = "";
      try {
          JSONArray jsonArray = new JSONArray();
          jsonArray.put(0, tn);
          json = jsonArray.toString();
      } catch (JSONException e) {
          e.printStackTrace();
      }
      return json;
  }
  </code></pre>
  
  <p>and full code is:</p>
  
  <pre><code>    try {
          URL url;
          HttpURLConnection urlConnection;
          url = new URL(makeCallUrl);
          urlConnection = (HttpURLConnection) url.openConnection();
          urlConnection.setRequestMethod("POST");
          urlConnection.setRequestProperty("Content-Type", "application/json");
          urlConnection.setRequestProperty("Authorization", String.format("%s %s", "Basic", secretKey));
          urlConnection.setUseCaches(false);
          urlConnection.setDoOutput(true);
          urlConnection.connect();
          // Setup the body of the url
          JSONObject json = new JSONObject();
  
          json.put("env", "dev");
          json.put("destNumbers", tn("+123123"));
  
          // Write the body on the wire
          BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(urlConnection.getOutputStream()));
          writer.write(json.toString());
          writer.flush();
          writer.close();
  
      } catch (IOException e) {
          Log.d(TAG, "IOException:" + e.getMessage());
          e.printStackTrace();
      }
  </code></pre>
  
  <p>If I try this, I got 400, Bad request exception.
  Please help me to pass an array to POST api </p>