0
I did a job in C# and now I need to connect this service with my bank on Firebase. The following is the method in Library for connection with the 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 the 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; }
}
THINK I was able to make the connection but I can’t see the correct content, the answer that returns is as follows:
RESTAPI: System.Collections.Generic.List`1[Testwindowsservice.Library+Items]
ps: that answer I write in a notebook.
What does that answer mean? Connected how do I "pan" this answer to format it?
Speaks @jbueno, improved my post this time? rs. I edited and put my class to which you refer in your reply (which lacks a Items structure). I made the adjustments you said but now the answer is blank.
– Henrique Gusmão
So, young man. you’ve improved a lot, I can understand your question at first. The point is that you involved some unnecessary things, your only problem (at least in the scope of the publication) was that you didn’t know what you were writing in the file. By the way, seeing this "problem" of yours, I feel obliged to say that you are lacking basis for you, it seems to me that you have parachuted and are trying to do something with C#. It would be good to study language first, have some knowledge base. I have the impression that you are completely lost in it.
– Jéf Bueno
About the solution: try to do this ->
Library.WriteErrorLog("RESTAPI: " + queryResult.Count);
and tell me what the written result was. By the way, you know how to debug the code?– Jéf Bueno
The answer was: RESTAPI: 1
– Henrique Gusmão
Well, that means your query has returned one item. Now, without further details, I have no way to help you.
– Jéf Bueno
Okay, thank you!!!
– Henrique Gusmão