I\'m attempting to use the documentation on the RestSharp GitHub wiki to implement calls to my REST API service but I\'m having an issue with the ExecuteAsync method in part
The following did the job
public async Task> ExecuteAsync(IRestRequest request) where T : class, new()
{
var client = new RestClient
{
BaseUrl = _baseUrl,
Authenticator = new HttpBasicAuthenticator(_useraname, _password),
Timeout = 3000,
};
var tcs = new TaskCompletionSource();
client.ExecuteAsync(request, restResponse =>
{
if (restResponse.ErrorException != null)
{
const string message = "Error retrieving response.";
throw new ApplicationException(message, restResponse.ErrorException);
}
tcs.SetResult(restResponse.Data);
});
return await tcs.Task as IRestResponse;
}