JSONArray initial value should be a string or collection or array
<p>I am beginner to JAVA with API.</p>

<p>The response That I'm getting during my program as follows:</p>

<p>*Object Response: </p>

<pre><code>    {
        "statusLine":{
            "reasonPhrase":"OK",
            "protocolVersion":{},
            "statusCode":200
        },
        "protocolVersion":{},
        "locale":"en_IN",
        "entity":{
            "repeatable":false,
            "content":{}
        }
    } 
</code></pre>

<p>Exception Occured. JSONArray initial value should be a string or collection or array.*</p>

<p>Unable to get full complete values in the results. I am getting only header details.</p>

<p>Please help me in get complete details from the API. using JAVA</p>

<pre><code>package IOT;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP;
import org.json.JSONObject;
import org.json.JSONArray;

public class HttpPostWithBody {

public static void main(String args[]) {
    String Message = "6f2159f998";

    try {
        new HttpPostWithBody().sendJSONData(Message);
    } catch (Exception E) {
        System.out.println("Exception Occured. " + E.getMessage());
    }
}

public String sendJSONData(String message) throws Exception {

    Map&lt; String, Object&gt; jsonValues = new HashMap&lt; String, Object&gt;();
    {
    jsonValues.put("thing_key", message);
    jsonValues.put("from", "2016/08/29 16:55:00");
    jsonValues.put("to", "2016/08/29 17:05:00");
    jsonValues.put("time_zone", "Mumbai");
    jsonValues.put("time_format", "str");
    jsonValues.put("per", 50);
    //jsonValues.put("metrics", "1st data");
    }
    JSONObject json = new JSONObject(jsonValues);

    String url = "https://api.datonis.io/api/v3/datonis_query/thing_data";

    DefaultHttpClient client = new DefaultHttpClient();
    HttpPost post = new HttpPost(url);
    post.setHeader("Content-Type", "application/json");
    post.setHeader("Accept", "application/json");
    post.setHeader("X-Auth-Token", "YZ0Sa7IfpdtAXQQ-2CNeAg");

    StringEntity entity = new StringEntity(json.toString(), "UTF8");
    System.out.println("This is the entity: " + entity);

    Gson gson = new GsonBuilder().setPrettyPrinting().create();
    JsonParser jp = new JsonParser();
    JsonElement je = jp.parse(json.toString());
    String prettyJsonString = gson.toJson(je);
    System.out.println("Pretty Json: " + prettyJsonString);

    entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));

    post.setEntity(entity);
    //this is your response:

    HttpResponse response = client.execute(post);

    JSONObject jo = new JSONObject(response);   
    System.out.println("Object Response: " + jo);

    JSONArray ab = new JSONArray(response);
    JSONObject cd = ab.getJSONObject(0); 

    System.out.println("Array Response: " + cd);
    System.out.println("Array Response: " + jo.getJSONArray("6f2159f998"));
    System.out.println("Connection Status: " + response.getStatusLine());
    return response.getStatusLine().toString();

    }
}
</code></pre>