Issue with Firebase database REST API URL having c

2019-08-01 08:40发布

问题:

Firebase is not able to store data if any of the node in the json tree path contain character "." i.e period

Example

https://.firebaseio.com/path/to/node/.json Will store the data in above specified json tree node.

However, consider below query where I have a "." character in my url

https://.firebaseio.com/path/to/node.speical/.json

It will return

{
"error": "Invalid path: Invalid token in path"
}

Is this something because firebase server have not handled this case appropriately?? Please suggest.

回答1:

Yes, there are a set of special characters that Firebase does not support in it's keys. From Firebase doc -

A child node's key cannot be longer than 768 bytes, nor deeper than 32 levels. It can include any unicode characters except for . $ # [ ] / and ASCII control characters 0-31 and 127.

You need to escape or encode those characters if they are present in your key. A simple character substitution encoding will work too.



回答2:

When you access the Firebase Database through its REST API, your URLs will end in .json. But aside from that, the . character is not allowed in Firebase Database paths. So node.special is not a valid node name.