Issue
Hi so I'm moving my app from a MySQL database to Firebase, but I'm having trouble getting the connection between my c# code and firebase set up.
So I have a Firestore database that looks like this:
[Firebase database with "Persons" collection containing one record with an auto-generated Id. This record contains Admin (set to true) and Fullname (set to PJ)][1] [1]: https://i.stack.imgur.com/FFF9A.png
I have this code:
public static async Task<List<Person>> GetAllPersons()
{
return (await firebase
.Child("Persons")
.OnceAsync<Person>()).Select(item => new Person
{
Fullname = item.Object.Fullname,
Admin = item.Object.Admin
}).ToList();
}
But when I try to execute the function i get this error message:
Firebase.Database.FirebaseException: Exception occured while processing the
request.
Url: https://moveeasy-72594.firebaseio.com/Persons/.json
Request Data:
Response: {
"error" : "404 Not Found"
}
I've set my rules to this:
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if request.auth == null;
}
}
}
Any advice would be appreciated
Solution
I suspect you may be using the wrong URL to access your database. If you created the database to be in Western Europe, its URL is one of these:
- https://moveeasy-72594.europe-west1.firebasedatabase.app/Persons.json
- https://moveeasy-72594-default-rtdb.europe-west1.firebasedatabase.app/Persons.json
Try initializing Firebase with these URLs and see if that works for you.
Answered By - Frank van Puffelen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.