Expected BEGIN_OBJECT but was STRING at line 1 column 1 path - Laravel to Retrofit 2 Expected BEGIN_OBJECT but was STRING at line 1 column 1 path - Laravel to Retrofit 2 json json

Expected BEGIN_OBJECT but was STRING at line 1 column 1 path - Laravel to Retrofit 2


I had this problem and it took me a lot of time to figure it out.

I found a solution here: https://stackoverflow.com/a/56903479/3971619

TLDR: The BASE_URL variable used to create the Retrofit object should not have anything after the /

Replace:

val authApiService = Retrofit.Builder()    .baseUrl("https://test.com/api/test") //There is path after the /    .addConverterFactory(GsonConverterFactory.create(gson))    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())    .build().create(AuthService::class.java)

By

val authApiService = Retrofit.Builder()    .baseUrl("https://test.com/") //It should only be the base url without a path    .addConverterFactory(GsonConverterFactory.create(gson))    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())    .build().create(ServiceClass::class.java)