nnnn nnnn - 11 months ago 155
Android Question

Using Retrofit 2 but, have Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

I make request get photos from Flickr, using Retrofit 2.

I create a class for parsing it:

public class FlickrResult {

private FlickrPhotos photos;

private String stat;

public FlickrPhotos getPhotos() {
return photos;

public class FlickrPhotos {

private int page;

private String pages;

private int perpage;

private String total;

private ArrayList<FlickrPhoto> photo;

public ArrayList<FlickrPhoto> getPhoto() {
return photo;

public class FlickrPhoto {

private String id;

private String owner;

private String secret;

private String server;

private int farm;

private String title;

private int ispublic;

private int isfriend;

private int isfamily;

public String getTitle() {
return title;



My build request is:

static {
gson = new GsonBuilder()

private static Retrofit buildRetrofit() {
Log.i(TAG, "onBuildRetrofitApiFactory");
return new Retrofit.Builder()

Retrofit interface

Call<FlickrResult> getPhotos(@Query("method") String method,
@Query("api_key") String key,
@Query("format") String format,
@Query ("nojsoncallbac") String nojsoncallbac

Me responsable is success, but problem in parsing. Have exeption:

java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

Please guys, i need you help!

Answer Source

Your Retrofit interface is wrong.

The paremeter "nojsoncallbac" is incorrect and should be "nojsoncallback".

This incorrect parameter causes the API to return a different format on the response

  "photos": {
  "page": 1,
  "pages": 10,
  "perpage": 100,
  "total": 1000,
  "photo": [