Reputation: 102
I am trying to pass an arraylist to php to do some operations. when i tested with postman i got the following resoponse..
{"correct_answers":"2","total_question":"5","message":"Great!. You need to score at least 60% of marks to move next level..","message_percentage":"40","saved_message":"success"}
But when I try to send the request i am getting this error..
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
this is my api interface
@POST("questions.php")
@FormUrlEncoded
Call<QuestionResult> correctQuestionData(@Field("tag") String tag, @Field("str_question_answer[]") ArrayList<QuestionAnswers> str_question_answer,
@Field("student_id") String student_id, @Field("level") String level);
Upvotes: 3
Views: 897
Reputation: 2275
I think you made mistake in QuestionResult class. It's format should be like
public class QuestionResult{
public String correct_answers;
public String total_question;
public String message;
public String message_percentage;
public String saved_message;
}
Upvotes: 0
Reputation: 2774
The problem is that Gson expecting an object, but is receiving a String, this is because the format of the JSON probably is wrong. The JSON has to start with
{
Please, review the JSON format.
EDIT: Review the parameters of your query, I think that you are sending others parameters instead of what you are putting in postman and the server responding with a String instead of a JSON
Upvotes: 2