step-up-labs / firebase-database-dotnet

C# library for Firebase Realtime Database.
MIT License
668 stars 168 forks source link

Invalid key name in startAt query parameter #297

Open AchuthanR opened 1 year ago

AchuthanR commented 1 year ago

I am using the offline database implementation. When I start streaming changes, the latest key present in the offline database is fetched and incremented in RealtimeDatabase.GetLatestKey() method and returned as I use StreamingOptions.LatestOnly. The returned string is used in the startAt="\<latest-key>" query parameter.

But when the latest key is something like -NBatwr2n20T2uW3aKlZ, I get an error as the last character Z will be made \ and it can't be used just like that in the query part. This is the exception data I get:

Url: https://\<project-id>-default-rtdb.firebaseio.com/\<path>/.json?orderBy="$key"&startAt="-NBatwr2n20T2uW3aKl\" Request Data: Response: { "error" : "Constraint key field must be a valid key name" }

I referred to the best answer under this stackoverflow question, but no method suggested there worked.

RPGFabi commented 1 year ago

Did you implement the .indexIsOn in your FIrebase? Think it is needed for special qerrys

AchuthanR commented 1 year ago

Did you implement the .indexIsOn in your FIrebase? Think it is needed for special qerrys

Firebase automatically indexes its children based on keys. So, no need to specify it explicitly. But, anyway, I tried it just now and it doesn't seem to work.