I have a webapi service and the controller of this service is calling a remote webapi to get data.
I have a sample controller which has the below test method :
[HttpGet("activity")]
public ActionResult<BoredAPIDM> GetActivity()
{
Processor pr = new Processor();
object data = pr.GetActivity();
Debug.WriteLine(data); // Breakpoint
return Ok();
}
and the Processor class has the below method :
public async Task GetRemoteActivity()
{
string baseURL = $"https://www.boredapi.com/api/activity";
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(baseURL);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await client.GetAsync("activity");
if (response.IsSuccessStatusCode)
{
string result = response.Content.ReadAsStringAsync().Result;
DataTable dt = JsonConvert.DeserializeObject<DataTable>(result);
}
else
{
Debug.WriteLine($"Error calling the API from {baseURL}");
}
}
}
As a result of this, what I am expecting is the data content which comes to the GetRemoteActivity() method but it does not come to GetActivity() method and the breakpoint on the debug line shows :
Id = 117, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"
I feel like I am missing a whole point; what is it ?