title: GSON Expected BEGIN_ARRAY but was STRING at line 1 error
body: <p>I am trying to parse a String array using Retrofit and GSON which is returned from the API:</p>
  
  <p>This is what the response normally looks like (CASE 1):</p>
  
  <pre><code>["Scan finished, scan information embedded in this object", "https://www.virustotal.com/url/297c349554bdc7e2f09a85be309f08cb2f16a9174068bd5bc6e298ed90a5eed9/analysis/1485313628/", 8, 64]
  </code></pre>
  
  <p>This is what the response looks like in a specific case (CASE 2):</p>
  
  <pre><code>["Scan request successfully queued, come back later for the report", "https://www.virustotal.com/url/d06ed0b4b29aab735ee7b85c5c0af98fd4d983edcc597afe60e4c4ac2e25ea08/analysis/1485847248/", null, null]
  </code></pre>
  
  <p>In this case (CASE 2), I am getting an error from Retrofit/GSON:</p>
  
  <pre><code>W/System.err: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 2 path $
  01-31 13:42:41.922 15746-15746/com.ssrij.testapp W/System.err:     at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:350)
  01-31 13:42:41.922 15746-15746/com.ssrij.testapp W/System.err:     at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:80)
  01-31 13:42:41.922 15746-15746/com.ssrij.testapp W/System.err:     at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
  01-31 13:42:41.922 15746-15746/com.ssrij.testapp W/System.err:     at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:37)
  01-31 13:42:41.922 15746-15746/com.ssrij.testapp W/System.err:     at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:25)
  01-31 13:42:41.922 15746-15746/com.ssrij.testapp W/System.err:     at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:117)
  01-31 13:42:41.922 15746-15746/com.ssrij.testapp W/System.err:     at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:211)
  01-31 13:42:41.922 15746-15746/com.ssrij.testapp W/System.err:     at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:106)
  01-31 13:42:41.922 15746-15746/com.ssrij.testapp W/System.err:     at okhttp3.RealCall$AsyncCall.execute(RealCall.java:133)
  01-31 13:42:41.922 15746-15746/com.ssrij.testapp W/System.err:     at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
  01-31 13:42:41.922 15746-15746/com.ssrij.testapp W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
  01-31 13:42:41.922 15746-15746/com.ssrij.testapp W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
  01-31 13:42:41.922 15746-15746/com.ssrij.testapp W/System.err:     at java.lang.Thread.run(Thread.java:761)
  </code></pre>
  
  <p>I call the API like this:</p>
  
  <pre><code>Call&lt;ArrayList&lt;String&gt;&gt; scanResults = myAPI.getScanResults(id);
  scanResults.enqueue(...)
  </code></pre>
  
  <p>and the array gets populated fine in the normal case (CASE 1), but in this case (CASE 2), it throws the error.</p>
  
  <p>I think it's because of the null values. I tried using a custom type adapter but it didn't fix the issue, also setting serializeNulls() on GsonBuilder didn't fix the issue.</p>
  
  <p>Does anyone know a solution?</p>
  
  <p>EDIT: After some more debugging, it seems like the server is returning a string in CASE 2 instead of the String array for some reason. When I visit the link manually, I do see the string array, but for some reason the response is String.</p>