bugthesystem / FireSharp

An asynchronous cross-platform .Net library for Firebase
The Unlicense
697 stars 147 forks source link

Simple PUSH throws an exception #95

Closed arikshik closed 7 years ago

arikshik commented 7 years ago

Hi - I'm new to Firebase, please advise what I'm doing wrong. I'm getting "An error occured while execute request. Path : Game , Method : POST" BTW - just making sure - I put the legacy database secret (from console) I have in the AuthSecret. Thanks.

The code:

    public static async void WriteToFirebase()
    {
        IFirebaseConfig config = new FirebaseConfig
        {
            BasePath  = "*********************************",
            AuthSecret = "********************************"
        };
        IFirebaseClient client = new FirebaseClient(config);
        PushResponse response = await client.PushAsync("Game", new Game
        {
            ID = "456",
            Name = "Birds"
        });
    }
arcosmin commented 7 years ago

Is your "Game" directly under the root node? If not you will need to specify the path to the Game node. For example if your node structure is root -> tournament -> Game you will need to modify the code to be:

 PushResponse response = await client.PushAsync("tournament\Game", new Game
        {
            ID = "456",
            Name = "Birds"
        });
arikshik commented 7 years ago

Tried it, doesn't work. It seems like any request I make fails on the same error, even a simple Get. Could it be something with the authentication?

arcosmin commented 7 years ago

Assuming you got the BasePath and AuthSecret right I don't think it is an authentication problem. Can you post your db structure from the Firebase console? you can hide the values, i'm only interested in the keys.

arikshik commented 7 years ago

Sure, simple JSON which corresponds to the test example: { "tournament" : { "Game" : { "ID" : "a", "Name" : "b" } } }

The code for GET: public static async void WriteToFirebase() { IFirebaseConfig config = new FirebaseConfig { AuthSecret = "**", BasePath = "**" };

        IFirebaseClient client = new FirebaseClient(config);

        FirebaseResponse response = await client.GetAsync("tournament/Game");
        Game g = response.ResultAs<Game>();
    }

The error: FirebaseException: An error occured while execute request. Path : tournament/Game , Method : GET

arikshik commented 7 years ago

BTW tried it with both right/left slash. Same error.

arikshik commented 7 years ago

ISSUE CAN BE CLOSED: I figured out this is a network issue, some proxy in my office preventing the REST calls from going out properly. The same code works good on a VM on Google cloud. Thanks.