JsonSyntaxException: java.lang.IllegalStateException: Expected an int but was BOOLEAN
que tal amigos, estoy intentando hacer una app que conecte con la plataforma moodle,
bueno a la hora de correr el programa me arroja el siguiente resultado:
JsonSyntaxException: java.lang.IllegalStateException: Expected an int but was BOOLEAN
ArrayList<MoodleCourse> mCourses = new ArrayList<MoodleCourse>();
String format = MoodleRestOption.RESPONSE_FORMAT;
String function = MoodleRestOption.FUNCTION_GET_ENROLLED_COURSES;
try {
// Adding all parameters.
String params = "&" + URLEncoder.encode("userid", "UTF-8") + "="
+ userId;
// Build a REST call url to make a call.
String restUrl = mUrl + "/webservice/rest/server.php" + "?wstoken="
+ token + "&wsfunction=" + function
+ "&moodlewsrestformat=" + format;
/
MoodleRestCall mrc = new MoodleRestCall();
Reader reader = mrc.fetchContent(restUrl, params);
GsonExclude ex = new GsonExclude();
Gson gson = new GsonBuilder()
.addDeserializationExclusionStrategy(ex)
.addSerializationExclusionStrategy(ex).create();
mCourses = gson.fromJson(reader,
new TypeToken<List<MoodleCourse>>() {
}.getType());
reader.close();
} catch (Exception e) {
Log.d(DEBUG_TAG, "URL encoding failed");
e.printStackTrace();
}
return mCourses;
}
- Inicie sesión o regístrese para enviar comentarios
El Json esta mal
esa exepcion te sale porque el Json que tienes que parsear, o llega nulo o no llega en un formato adecuado, tienes que verificar antes con algun cliente las respuestas que te manda el servidor, para saber como es que vas a transformar esas respuestas para que sean aceptadas por la aplicacion