How can we improve the API?

Create example code to use the API in c#

It would be great to have official or community supported examples of how to the use the API in C# (.NET). Code samples or reference implementations would optimally cover how to handle authentication, fetching content and complying with the FUMS reporting.

2 votes
Vote
Sign in
(thinking…)
Password icon
Signed in as (Sign out)
You have left! (?) (thinking…)
John Mark Mitchell shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

2 comments

Sign in
(thinking…)
Password icon
Signed in as (Sign out)
Submitting...
  • chuckbarkertech commented  ·   ·  Flag as inappropriate

    Here is how I call it in a console application.

    static void Main(string[] args)
    {
    String apikey = Properties.Settings.Default.apikey;
    String apipassword = Properties.Settings.Default.apipassword;
    Task<String> s = SampleRequest(apikey, apipassword);
    while (!s.IsCompleted)
    {
    Console.Write(".");
    Thread.Sleep(100);
    }
    Console.WriteLine();
    if (s.IsCanceled || s.IsFaulted)
    Console.WriteLine("Connection to server did not complete");
    else
    Console.WriteLine("Response Length: {0}", s.Result.Length);
    Console.WriteLine();
    }

  • chuckbarkertech commented  ·   ·  Flag as inappropriate

    The below demonstrates spawning a thread to pull the book list. It includes authentication. I'll add some more later and move this into Github.

    private static Task<String> SampleRequest(String apikey, String apipassword)
    {
    using (WebClient wc = new WebClient())
    {
    wc.Credentials = new NetworkCredential(apikey, apipassword);
    return wc.DownloadStringTaskAsync("https://bibles.org/versions/eng-GNTD/books.xml");
    }
    }

Feedback and Knowledge Base