0

Hello I am calling API on my payment success event and send data on our server via API and it was working before but suddenly stop working below is my error and code

Error

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

Code

 Gson gson = new GsonBuilder().setLenient().create();
        OkHttpClient.Builder okClientBuilder = new OkHttpClient.Builder().connectTimeout(1, TimeUnit.MINUTES)
                .readTimeout(1, TimeUnit.MINUTES);
        OkHttpClient okHttpClient = new OkHttpClient().newBuilder()
                .connectTimeout(30, TimeUnit.SECONDS)
                .readTimeout(30, TimeUnit.SECONDS)
                .writeTimeout(30, TimeUnit.SECONDS)
                .build();
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(Base_url.url)
                .client(okHttpClient)
                .addConverterFactory(GsonConverterFactory.create(gson))
                .build();
3
  • Maybe server-side response changed so maybe you need to change the model class according to server response. Please check server-side response and your model classes. Commented Mar 12, 2020 at 12:11
  • @ Nilesh Panchal this error is from onFailure so it can not be error on response Commented Mar 12, 2020 at 12:19
  • have you checked in postman that API is working properly in it? Commented Mar 12, 2020 at 12:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.