I'm facing issue with http call.
Error Message is : httpclient postasync an error occurred while sending the request
`public TResult PostAPI(string url, T reqparams, List<KeyValuePair<string, string>> formParameters = null, string jsonString = "", List<KeyValuePair<string, string>> headers = null)
{
HttpContent contentPost = null;
if (headers != null)
{
AddHeaders(headers);
}
if (formParameters != null)
{
var formContent = new FormUrlEncodedContent(formParameters);
contentPost = formContent;
}
else if (!string.IsNullOrEmpty(jsonString))
{
var content = new StringContent(jsonString, Encoding.UTF8, "application/json");
contentPost = content;
}
string s = JsonConvert.SerializeObject(reqparams);
var contents = new StringContent(s, Encoding.UTF8, "application/json");
contentPost = contents;
//client. = 3000;
var response = client.PostAsync(url, contentPost).Result; //Task.Run(() => client.PostAsync(url, contentPost)).Result;
IEnumerable<string> responseHeaders;
response.Headers.TryGetValues("Authorization", out responseHeaders);
if (responseHeaders != null && responseHeaders.Any())
{
AccessToken = responseHeaders.Select(x => x).FirstOrDefault();
}
var apiResult = response.Content.ReadAsStringAsync().Result;
var result = JsonConvert.DeserializeObject<TResult>(apiResult);
return result;
}
`
below is Inner exceptions
at System.Net.Http.HttpClientHandler+d__63.MoveNext () [0x004ab] in <7736395a6c71409691a34accfc621095>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Net.Http.HttpClient+d__49.MoveNext () [0x000ca] in <7736395a6c71409691a34accfc621095>:0