step-up-labs / firebase-database-dotnet

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

Trying to get data from the server #279

Closed eduardoagr closed 2 years ago

eduardoagr commented 2 years ago

Hello I am trying to get a particular object by ID, and I am getting this exception

Firebase.Database.FirebaseException: 'Exception occured while processing the request. Url: https://duonotes-f2b77-default-rtdb.europe-west1.firebasedatabase.app/Notes/-MxgjxhpwoBeOLBy83rh/.json Request Data: Response: {"CreatedDate":"Wednesday, March 9, 2022","FileLocation":"https://notesbucket.blob.core.windows.net/notes/1.html","Name":"1","NotebookId":"-MxgjqZ9JShzHH21k_RS"}'

This is the code that I use

` public async void ReadOlyOnceAsync(string NoteId) {

        var objects = await firebaseClient
                    .Child(AppConstant.Notes)
                    .Child(NoteId).OnceAsync<Note>();

        foreach (var x in objects) {

            System.Console.WriteLine(x.Object);
        }
    }`

But because I just want to return the specific item

I copy and paste from documentation

but it doesn't do anything


`                   var obj = await firebaseClient
                        .Child(AppConstant.Notes)
                        .Child(NoteId).OnceAsync<NotebookNote>();

            return obj;`
eduardoagr commented 2 years ago

I also tried with this code

`public async Task ReadByIdAsync(string ChildName, string Id) {

       return (NotebookNote)await firebaseClient
          .Child(ChildName)
          .Child(Id)
          .OnceAsync<NotebookNote>();
    }
    `

and got this error

Firebase.Database.FirebaseException: 'Exception occured while processing the request. Url: https://duonotes-f2b77-default-rtdb.europe-west1.firebasedatabase.app/Notes/-MxgjxhpwoBeOLBy83rh/.json Request Data: Response: {"CreatedDate":"Wednesday, March 9, 2022","FileLocation":"https://notesbucket.blob.core.windows.net/notes/1.html","Name":"1","NotebookId":"-MxgjqZ9JShzHH21k_RS"}' The strange part is the the Response has all the data I need