I have a function
private async Task callApi(string baseAddress, string endpoint, Log log)
{
var client = new HttpClient();
HttpContent content = new StringContent(JsonConvert.SerializeObject(log), Encoding.UTF8, "application/json");
client.BaseAddress = new Uri(baseAddress);
await client.PostAsync(endpoint, content);
client.Dispose();
}
This works when deployed but I've written a test to make sure it works. However when the test runs, the call is never made.
If I change the line
await client.PostAsync(endpoint, content);
To
_ = client.PostAsync(endpoint, content).Result;
Then it does work, but I want to avoid using Result as it can cause blockages.
Edit: It's worth mentioning I don't care about the result of the call. It's should be sent and then the result doesn't matter to me.