Unexpected Token # In Json At Position 0 Error On Android Studio Using Retrofit2
Solution 1:
As you are using the GsonConverterFactory
, I think it's expecting json (or to serialize to JSON) when you use the @Body
annotation. As you are passing a raw String value I think this is where it errors.
Please disregard the answer above. The GsonConverterFactory will serialise your own Type to JSON, however you are sending in a raw String value. This will not be serialized so the body of the post for an id of 3 will be "3" - I think the api you are calling for deleteUser is expecting JSON in the body which you are not sending which is why you are getting the error. I would check the docs of the Firebase API call you are making to see what format it expects the post body to be in. It is more likely to be something like:
{"userId":"3"}
If this is the case then you would need a class like:
publicclassUser {
privateString userId;
publicUser(String userId){
this.userId = userId;
}
}
You are currently sending a " character as the first character when it's probably expecting a { to signify starting a JSON object
Post a Comment for "Unexpected Token # In Json At Position 0 Error On Android Studio Using Retrofit2"