public async Task <T> SendWebRequestAsync <T>(string url, string method = "POST", Dictionary <string, object> parameters = null) { try { var request = _requestFactory.Create(url, parameters, method); var response = (HttpWebResponse)(await request.GetResponseAsync()); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); var responseObject = _dataFormatter.ParseResponseString <T>(responseString); return(responseObject.Result); } //TODO catch non-general exception for Bad Requests catch (Exception e) { int errorCode = _dataFormatter.FormServerApiErrorCode(e.Message); throw new ApiRequestException(e.Message, errorCode); } }