Get Videos - no index response

OK trying to use the new API to pull users videos however using the Android volley Method i getting no response, states index 0 of 0.
the user in question has videos so it should have responses.

example of my code

   String url = "https://api.twitch.tv/helix/videos?user_id=64578628";

    // Request a string response from the provided URL.
    final JsonObjectRequest DivanRequest = new JsonObjectRequest
            (com.android.volley.Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    try {

                        JSONObject jsonObject = response;
                        JSONArray JA = jsonObject.getJSONArray("data");
                        for (int i = 0; i < response.length(); i++) {
                            JSONObject object = JA.getJSONObject(i);
                            String Name = object.getString("title");
                            aldrenTitle.append(Name);
                        }


                        JSONObject jsonObject2 = response;
                        JSONArray JA2 = jsonObject2.getJSONArray("data");
                        for (int i = 0; i < response.length(); i++) {
                            JSONObject object = JA2.getJSONObject(i);
                            String Time = object.getString("duration");
                            aldrenTime.append(Time);
                        }


                            JSONObject jsonObject3 = response;
                            JSONArray JA3 = jsonObject3.getJSONArray("data");
                            for (int i = 0; i < response.length(); i++) {
                                JSONObject object = JA3.getJSONObject(i);
                                String Image = object.getString("thumbnail_url");
                                new DownLoadImageTask(aldrenVideo).execute(Image);
                            }


                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }





            }


                    , new Response.ErrorListener()


            {

                @Override
                public void onErrorResponse(VolleyError error) {

                    Log.e("VOLLEY", "ERROR");

                }
            })


    {    //this is the part, that adds the header to the request

        @Override
        public Map<String, String> getHeaders() {
            Map<String, String> params = new HashMap<String, String>();
            params.put("Client-ID", "actual client id");
            params.put("content-type", "application/json");
            return params;
        }


    };

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

At a guess. It sounds like you have a “SSL netogitaiton fail” or you just plain failed to connect to the API.

Test for a HTTP Response code and/or turn on verbose logging to get more useful output.

It feels like a problem with the implementation not a problem with the API

OK… I am a complete noob(confirmed i am) apparently as i figured out the issue was just that no response from the HTTP Request… because i forgot to instantiate it. well glad got that figured out.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.