0

I am getting following error:

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 2 path $

I am using following code:

In Application Class:

  public static void setupRetrofit() {
    OkHttpClient client = new OkHttpClient();
    client.interceptors().add(new NewRequestIntercepter(mContext));

    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .client(client)
            .build();

    service = retrofit.create(ApiService.class);
}

public static ApiService getApiService() {
    return service;
}

}

Interface Class

 public interface ApiService
 {
    @POST("users")
    Call<String> registerUser(@Body JsonObject jsonObject);
}

Login Activity Class

 JsonObject Obj = new JsonObject();
 JsonObject userObj = new JsonObject();
 Obj.addProperty("email", "mark@gmail.com");
 Obj.addProperty("name", "Mark"));
 Obj.addProperty("gender", "Male");
 userObj.addProperty("userInfo",obj); 

 Call<String> registerUserAPI = SoulCurry.getApiService().registerUser(userObj);
        registerUserAPI.enqueue(new Callback<String>() {
            @Override
            public void onResponse(retrofit.Response<String> response, Retrofit retrofit) {
                if (response.isSuccess())
                    CurryLogger.d("LoginActivity", response.toString());
            }

            @Override
            public void onFailure(Throwable t) {
                CurryLogger.d("Fail");
            }
        });

    } catch (Exception e) {
        e.printStackTrace();
    }
}
user1288005
  • 890
  • 2
  • 16
  • 36

0 Answers0