Forgive my lack of knowlegde, I'm a database guy although I dabbled a bit with C# a while back. I am trying to figure how to get this API running.
The API I'm trying to consume is from https://rapidapi.com/api-sports/api/api-nba/. There is barely any documentation to guide me.
Here's my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using unirest_net.http;
using unirest_net;
namespace NBA_test
{
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Start ...");
Task<HttpResponse<MyClass.RootObject>> response = Unirest.get("https://api-nba-v1.p.rapidapi.com/gameDetails/5162")
.header("X-RapidAPI-Host", "api-nba-v1.p.rapidapi.com")
.header("X-RapidAPI-Key", "myKey")
.asJsonAsync<MyClass.RootObject>();
var status = response.Status;
Console.WriteLine("End ....");
}
}
public class MyClass
{
public class Result
{
public string seasonYear { get; set; }
public int gameId { get; set; }
public string arena { get; set; }
}
public class RootObject
{
public List<Result> results { get; set; }
}
}
}
var status goes from Created to Running and then that's it, program closes. No error message but I don't know how to get the JSON out of this API. I know I'm missing something but don't know what.