douchebag
API integration issue in .NET core framework.
private static string HttpPostRequest(string url, string data, string authorization)
{
string finalUrl = url;
HttpRequestMessage httpRequestMessage = new HttpRequestMessage() { };
httpRequestMessage.Content = new StringContent(data, Encoding.UTF8, "application/json");
httpRequestMessage.Method = HttpMethod.Post;
httpRequestMessage.Headers.Add("Authorization", authorization);
httpRequestMessage.RequestUri = new Uri(finalUrl);
HttpClient httpClient = new HttpClient() { Timeout = TimeSpan.FromMinutes(5) };
HttpResponseMessage httpResponseMessage = httpClient.SendAsync(httpRequestMessage).Result;
using (StreamReader reader = new StreamReader(httpResponseMessage.Content.ReadAsStream()))
{
return reader.ReadToEnd();
}
}
127 replies