public class RestClient { public static async Task<T> CallServiceAsync<T>(string token, string endPoint, string url, object requestBodyObject, string method, string operation = null) where T : class { if (token == null) throw new Exception("Please provide token"); // Initialize an HttpWebRequest for the current URL. var webReq = (HttpWebRequest)WebRequest.Create(endPoint + url); webReq.Method = method; webReq.Accept = "application/json"; //Add basic authentication header if username is supplied if (!string.IsNullOrEmpty(token)) ...