Could someone please help me modify the code below:

client.ExecuteAsync(request, response => {
    Console.WriteLine(response.Content);
});

Basically I want to use ExecuteAsync method above but don't want to print but return response.Content to the caller.

Is there any easy way to achieve this?

I tried this but doesnt' work:

public T Execute<T>(RestRequest request) where T : new()
{
    var client = new RestClient();
    client.BaseUrl = BaseUrl;
    client.Authenticator = new HttpBasicAuthenticator(_accountSid, _secretKey);
    request.AddParameter("AccountSid", _accountSid, ParameterType.UrlSegment); // used on every request
    var response = client.ExecuteAsync(request, response => {
        return response.data);
    });
}

The above code is from https://github.com/restsharp/RestSharp

Edit
Report