public string connectionApiPost<T>(string language, string ApiControllerName, string functionName, T modal)
{
try
{
using (var client = new HttpClient())
{
string path = "http://localhost:" + localHostNumberAPI + "/api/" + ApiControllerName + "/" + functionName;
// Assuming the API is in the same web application.
string baseUrl = System.Web.HttpContext.Current
.Request.Url
.GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped);
client.BaseAddress = new Uri(baseUrl);
string result = client.PostAsync(path + "?language=" + language, modal, new JsonMediaTypeFormatter())
.Result
.Content
.ReadAsAsync<string>()
.Result;
// System.Net.Http.HttpContent content
return result;
}
}