RestSharp connected with Firebase but does not show result

0

I've made a service on C # and now I need to connect this service to my bank on FireBase . The following is the Library method for connecting to FireBase :

public static void restAPI()
    {
        var client = new RestClient("https://teste.firebaseio.com/");
        var request = new RestRequest("users.json", Method.GET);
        var queryResult = client.Execute<List<Items>>(request).Data;

        Library.WriteErrorLog("RESTAPI: " + queryResult);
    }

Function in Shceduler to initialize the service and call the method:

protected override void OnStart(string[] args)
    {
        Library.restAPI();
        if (Library.IsConnected())
        {
            Library.WriteErrorLog("////// Com conexão! //////");
            timer1 = new Timer();
            this.timer1.Interval = 3000;
            this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_Tick);
            Library.WriteErrorLog(">> Test Window Service iniciado! <<");
            if (!File.Exists(docBase))
            {
                File.Copy(pricetabLocal, docBase);
                listaBase = Library.MontarListaBase(docBase, ref copiado);
                Library.WriteErrorLog("<< FIM! >>" + copiado);
            }
            else
            {
                Library.WriteErrorLog("Ja existe um arquivo com este nome!");
                listaBase = Library.MontarListaBase(docBase, ref copiado);
                Library.WriteErrorLog("<< FIM! >>" + copiado);
            }
            timer1.Enabled = true;
        }
        else
        {
            Library.WriteErrorLog("////// Sem conexão! //////");
        }
    }

Public Class Items:

public class Items
    {
        public string usuarios { get; set; }
    }

ACHO I was able to make the connection but I can not see the correct content, the answer that returns is as follows:

  

RESTAPI: System.Collections.Generic.List'1 [TestWindowsService.Library + Items]

ps: This answer I write in a notebook.

This answer means what? If I connected, how do I "pan" this response to format it?

    
asked by anonymous 01.02.2017 / 17:51

2 answers

1

This is the default output pro type List<T> .

If you want to specify what should be written to the file, do so

public static void restAPI()
{
    var client = new RestClient("https://segundo-chat.firebaseio.com/");
    var request = new RestRequest("users.json", Method.GET);
    var queryResult = client.Execute<List<Items>>(request).Data;

    foreach(Items item in queryResult)
    {
        Library.WriteErrorLog("Resultado: " + item.usuarios);
    }
}
    
01.02.2017 / 17:56
1

< ANSWER >

To get what's in the FireBase database in the JSON format I've just modified my method:

public static void restAPI()
    {
        var client = new RestClient("https://teste.firebaseio.com/.json");
        var request = new RestRequest("", Method.GET);
        request.RequestFormat = DataFormat.Json;
        IRestResponse requestget = client.Execute(request);
        Library.WriteErrorLog("RESTAPI: " + requestget.Content);
    }
    
02.02.2017 / 12:40