Andrea Andrea - 1 month ago 6
Android Question

Firebase database: invalid token in path

my question is this, I´m getting this error:

com.google.firebase.database.DatabaseException: Firebase Database error: Invalid token in path
, when I update a User´s node which from this code:

Map<String, Object> userUpdate = new HashMap<>();
userUpdate.put("/" + Constants.Users + "/" + userEncEmail + "/profile_data/age", age);
userUpdate.put("/" + Constants.Users + "/" + userEncEmail + "/profile_data/email", userEmail);
userUpdate.put("/" + Constants.Users + "/" + userEncEmail + "/profile_data/gender", gender);
userUpdate.put("/" + Constants.Users + "/" + userEncEmail + "/profile_data/name", userName);
userUpdate.put("/" + Constants.Users + "/" + userEncEmail + "/profile_data/photo", "");
userUpdate.put("/" + Constants.Users + "/" + userEncEmail + "/profile_data/video", "");

userUpdate.put("/" + Constants.Users + "/" + userEncEmail + "/chat_data/osPlayerID", "");
userUpdate.put("/" + Constants.Users + "/" + userEncEmail + "/chat_data/name", userName);
userUpdate.put("/" + Constants.Users + "/" + userEncEmail + "/chat_data/photo", "");
userUpdate.put("/" + Constants.Users + "/" + userEncEmail + "/chat_data/video", "");

userUpdate.put("/" + Constants.Users + "/" + userEncEmail + "/status", false);//Set false by default

FirebaseDatabase.getInstance().getReference().updateChildren(userUpdate).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {


The rules from Firebase Database to this specific node are: true for write and read.

The Json expected is:

{
$UserEMail: {
chat_data: {
name: "",
osPlayerID: "",
photo: "",
video: ""
},
profile_data: {
age: (int),
email: "";
gender: (int),
name: "",
photo: "",
video: ""
},
status: (boolean)
}
}

Answer

The problem was that i was trying to insert an email like so email@example.com when Firebase doesn´t accept dots as part of a key of a node