title: How to get list of things in Retrofit
body: <p>There's something about Retrofit that I'm not getting. I'm following examples on the web, but can't get it to even compile. I am able to access the data from the RESTful service via old school (i.e. HttpGet/HttpResoponse) so I know the service works. It returns a bunch of EmployeeData (as oppose to just one EmployeeData)</p>
  
  <p>In the app gradle file:</p>
  
  <pre><code>dependencies {
      ...
      compile 'com.google.code.gson:gson:2.7'
      compile 'com.squareup.retrofit2:retrofit:2.1.0'
      compile 'com.squareup.retrofit2:converter-gson:2.1.0'
      ...
  }
  </code></pre>
  
  <p>The url for the RESTful service endpoint is:
  <a href="https://com.somewhere/PhoneDirectoryService/api/Employees/" rel="nofollow">https://com.somewhere/PhoneDirectoryService/api/Employees/</a></p>
  
  <p>I have defined a string for the base url:</p>
  
  <pre><code>&lt;string name="https_phone_directory_service_baseurl"&gt;https://com.somewherePhoneDirectoryService/api/&lt;/string&gt;
  </code></pre>
  
  <p>Interface</p>
  
  <pre><code>public interface EmployeesService {
      @GET("Employees.json") //  the string in the GET is end part of the endpoint url
      public Call&lt;List&lt;EmployeeEndpointResponse&gt;&gt; listEmployees();
  }
  </code></pre>
  
  <p>Response</p>
  
  <pre><code>public class EmployeeEndpointResponse {
  
      private List&lt;EmployeeData&gt; employees; // EmployeeData is a POJO
  
      // public constructor is necessary for collections
      public EmployeeEndpointResponse() {
          employees = new ArrayList&lt;EmployeeData&gt;(); 
      }
  
      public static EmployeeEndpointResponse parseJSON(String response) {
          GsonBuilder gsonBuilder = new GsonBuilder();
          gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
          Type collectionType = new TypeToken&lt;List&lt;EmployeeData&gt;&gt;(){}.getType();
          Gson gson = gsonBuilder.create();
          EmployeeEndpointResponse employeeEndpointResponse = gson.fromJson(response, EmployeeEndpointResponse.class);
          return employeeEndpointResponse;
      }
  }
  </code></pre>
  
  <p>Get the data</p>
  
  <pre><code>public static boolean getEmployeeData(Context context) {
  
      Resources resources = context.getResources();
      URI uri = null;
      try {
          uri = new URI(resources.getString(R.string.https_phone_directory_service_baseurl));
      }
      catch (URISyntaxException exception) {
          Log.e("getEmployeeData", exception.toString());
      }
  
      Retrofit retrofit = new Retrofit.Builder()
              .baseUrl(uri.toString())
              .addConverterFactory(GsonConverterFactory.create())
              .build();
      Call&lt;List&lt;EmployeeEndpointResponse&gt;&gt; call = service.listEmployees();
  
      EmployeesService service = retrofit.create(EmployeesService.class);
  
      // this does not compile 
      // error: &lt;anonymous com.somewhere.utilities.Utilities$1&gt; is not 
      // abstract and does not override abstract method 
      // onFailure(Call&lt;List&lt;EmployeeEndpointResponse&gt;&gt;,Throwable) in Callback
      call.enqueue(new Callback&lt;List&lt;EmployeeEndpointResponse&gt;&gt;() {
          @Override
          public void onResponse(Response&lt;List&lt;EmployeeEndpointResponse&gt;&gt; response) {
              List&lt;EmployeeEndpointResponse&gt; myList = response.body();
              // Successfull request, do something with the retrieved messages
          }
  
          @Override
          public void onFailure(Throwable t) {
              // Failed request.
          }
      });
  
      // so I tried this which gives compile error
      // retrofit2.Callback&lt;java.util.List   
      // &lt;com.somewhere.gson.EmployeeEndpointResponse&gt;&gt;)
      // in Call cannot be applied to anonymous retrofit2.Callback  
      // &lt;com.somewhere.gson.EmployeeEndpointResponse&gt;)         
      call.enqueue(new Callback&lt;EmployeeEndpointResponse&gt;() {
          @Override
          public void onResponse(Call&lt;EmployeeEndpointResponse&gt; call, Response&lt;EmployeeEndpointResponse&gt; response) {
              // handle response here
              EmployeeEndpointResponse employeeEndpointResponse = (EmployeeEndpointResponse)response.body();
          }
  
          @Override
          public void onFailure(Call&lt;EmployeeEndpointResponse&gt; call, Throwable t) {
  
          }
      });  
  
  }
  </code></pre>
  
  <p>What do I need to do?</p>
  
  <p>Data looks like: </p>
  
  <pre><code>[
  {"Name":"Smith, Ken J.",
  "Cell":"",
  "EmailAddress":"Ken.Smith@somewhere.com",
  "Location":"West",
  "Phone":"555-555-5555",
  "Address":"PO Box 555 5555 Del Norte",
  "City":"Jackson",
  "State":"WY",
  "Zip":"85555",
  "Latitude":42.24976,
  "Longitude":-107.82171},
  
  {"Name":"Cox, Daniel B.",
  "Cell":"",
  "EmailAddress":"daniel.cox@somewhere.com",
  "Location":"West",
  "Phone":"(555) 555-5516",
  etc ...}
  ]
  </code></pre>