Simple Service Call

Hello, I have a .NET Framework (not Core) web service I am attempting to create. Below is the simple code I am attempting to run, it is placed within a controller as the default get action.

public async Task Get()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);

// Request headers
client.DefaultRequestHeaders.Add("Bb-Api-Subscription-Key", “{my subscription key}");
client.DefaultRequestHeaders.Add("Authorization", "Bearer {my auth code}");

// Request parameters
var uri = "https://api.sky.blackbaud.com/treasury/v1/bankaccounts?" + queryString;

var response = await client.GetAsync(uri);
}

When I call and debug the code locally in Visual Studio on my machine I am able to see the intended results in the response variable. However when I publish the code to my server I get the error below.

An asynchronous module or handler completed while an asynchronous operation was still pending.

This is regardless whether the return type is void (as is in the examples) or changed to Task. I'm not very familiar with await, async, etc and have ha ddifficulty getting this running from the beginning.

Please help, thanks.

Thom

Categories