Advertisement
Guest User

Untitled

a guest
May 17th, 2016
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. Caused by: java.lang.IllegalArgumentException: Unable to create @Body converter for class com.iclienttech.ict_3.farm.models.LoginDetails (parameter #1)
  2.  
  3. compile 'com.squareup.retrofit2:retrofit:2.0.2'
  4. compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
  5. compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta3'
  6.  
  7. public interface LoginAPI {
  8. @POST("/farm/login_screen.php")
  9. Call<LoginAPIResponse> userDetails (@Body LoginDetails user);
  10. }
  11.  
  12. userId = userEmailId.getText().toString();
  13. password = userPassword.getText().toString();
  14. final LoginDetails user = new LoginDetails();
  15. user.setEmailId(userId);
  16. user.setPassword(password);
  17. loginAPIResponses = new LoginAPIResponse();
  18. AsyncTask performLogin = new AsyncTask() {
  19. @Override
  20. protected Object doInBackground(Object[] params) {
  21. loginAPIResponses = FarmUtils.getInstance().postUserDetails(user);
  22. return null;
  23. }
  24. };
  25. performLogin.execute();
  26. //Utils.Class
  27. public LoginAPIResponse postUserDetails(LoginDetails user) {
  28. HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
  29. interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
  30. OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
  31. Retrofit retrofit = new Retrofit.Builder()
  32. .baseUrl(farmURL)
  33. .addConverterFactory(GsonConverterFactory.create())
  34. .client(client)
  35. .build();
  36. LoginAPI loginAPI = retrofit.create(LoginAPI.class);
  37. try {
  38. Response<LoginAPIResponse> response = loginAPI.userDetails(user).execute();
  39. apiResponse = response.body();
  40. } catch (IOException e) {
  41. e.printStackTrace();
  42. }
  43. return apiResponse;
  44. }
  45.  
  46. public class LoginDetails {
  47.  
  48. @SerializedName("email_id")
  49. @Expose
  50. private String emailId;
  51. @SerializedName("password")
  52. @Expose
  53. private String password;
  54.  
  55. /**
  56. *
  57. * @return
  58. * The emailId
  59. */
  60. public String getEmailId() {
  61. return emailId;
  62. }
  63.  
  64. /**
  65. *
  66. * @param emailId
  67. * The email_id
  68. */
  69. public void setEmailId(String emailId) {
  70. this.emailId = emailId;
  71. }
  72.  
  73. /**
  74. *
  75. * @return
  76. * The password
  77. */
  78. public String getPassword() {
  79. return password;
  80. }
  81.  
  82. /**
  83. *
  84. * @param password
  85. * The password
  86. */
  87. public void setPassword(String password) {
  88. this.password = password;
  89. }
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement