I was doing every post method of my app using this method:
1-This is the interface where I do my get and post methods:
@POST("feedback/challenge/newRating")
Call<IncreasedChallengeFeedback> challengeFeedbackIncreaseRating(@Body IncreasedChallengeFeedback increasedFeedbackChallenge);
2- the method to do the call
public void increaseRatingCFb(IncreasedChallengeFeedback increasedChallengeFeedback) {
Gson gson = new GsonBuilder()
.setLenient()
.create();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://10.0.2.2:3000/")
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
api = retrofit.create(INodeJS.class);
Call<IncreasedChallengeFeedback> call = api.challengeFeedbackIncreaseRating(increasedChallengeFeedback);
call.enqueue(new Callback<IncreasedChallengeFeedback>() {
@Override
public void onResponse(Call<IncreasedChallengeFeedback> call, Response<IncreasedChallengeFeedback> response) {
if (!response.isSuccessful()) {
System.out.println("!= Successful" + response.code());
return;
}
}
@Override
public void onFailure(Call<IncreasedChallengeFeedback> call, Throwable t) {
System.out.println("OnFailure: " + t.getMessage());
}
});
}
3- Here I just create an object of the class to use with the method
holder.likeButton.setOnLikeListener(new OnLikeListener() {
@Override
public void liked(LikeButton likeButton) {
IncreasedChallengeFeedback icfb = new IncreasedChallengeFeedback("8","2");
increaseRatingCFb(icfb);
}
4- And finally here its the class
public class IncreasedChallengeFeedback {
private String cFeedbackRating;
private String cFeedbackID;
public IncreasedChallengeFeedback(String cFeedbackRating, String cFeedbackID) {
this.cFeedbackRating = cFeedbackRating;
this.cFeedbackID = cFeedbackID;
}
}
And with this I am getting this errors:
Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
So I added this:
Gson gson = new GsonBuilder()
.setLenient()
.create();
And then the error changes to this:
Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
The thing is that I did all my other posts and get methods using that method and then suddenly I'm stuck with this errors.