public async Task <string> Send(NameValueCollection parameters) { if (string.IsNullOrWhiteSpace(_parameters.CallbackApiUrl)) { return(null); } var targerUrl = $"{_parameters.CallbackApiUrl}{(_parameters.CallbackApiUrl.IndexOf("?", StringComparison.Ordinal) < 0 ? "?" : "&")}apikey={_parameters.ApiKey}"; StringBuilder sb = new StringBuilder(); foreach (string key in parameters.AllKeys) { if (sb.Length > 0) { sb.Append("&"); } sb.AppendFormat("{0}={1}", key, HttpUtility.UrlEncode(parameters[key])); } _parameters.Log?.Invoke($"WorkflowProviderWebApi Send request {targerUrl}"); var request = (HttpWebRequest)WebRequest.Create(targerUrl); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; using (var stream = await request.GetRequestStreamAsync()) { byte[] buffer = Encoding.Default.GetBytes(sb.ToString()); await stream.WriteAsync(buffer, 0, buffer.Length); } var response = (HttpWebResponse)await request.GetResponseAsync(); var responseString = await new StreamReader(response.GetResponseStream()).ReadToEndAsync(); return(HttpUtility.UrlDecode(responseString)); }