- Server operating system version
- Microsoft Windows Server 2022
- Plesk version and microupdate number
- Plesk Obsidian v18.0.62_build20240724.14 os_Windows 2012/2016/2019/2022
For a few days now, when I try to install LetsEncrypt certificates, I get the error 415 Unsupported Media Type only in that call. I have tried other calls and they don't give an error. It only gives it in that one.
I use C# to make the calls. I attach the code
I use C# to make the calls. I attach the code
private void InitializeClient()
{
apiClient = new HttpClient();
apiClient.BaseAddress = new Uri(hostUrl);
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
apiClient.DefaultRequestHeaders.Clear();
apiClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
ServicePointManager.MaxServicePointIdleTime = int.MaxValue;
var byteArray = Encoding.ASCII.GetBytes(string.Format("{0}:{1}", user, pass));
apiClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
}
//NO WORKS
public async Task<APIResult> InstalarRenvarSSL(string dominio)
{
var ls = new SSLParams();
List<string> @params = new List<string>();
@params.Add("--exec");
@params.Add("letsencrypt");
@params.Add("cli.php");
@params.Add("-d");
@params.Add(dominio);
if (dominio.StartsWith("www."))
{
@params.Add("-d");
@params.Add(dominio.Replace("www.",""));
}
@params.Add("-m");
@params.Add("[email protected]");
ls.@params = @params;
StringContent cont = new StringContent(JsonConvert.SerializeObject(ls));
using (HttpResponseMessage response = await apiClient.PostAsync("/api/v2/cli/extension/call", cont))
{
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<APIResult>(content);
return result;
}
else
throw new Exception(response.ReasonPhrase);
}
}
//THIS WORKS
public async Task<bool> ObtExtensiones()
{
using (HttpResponseMessage response = await apiClient.GetAsync("/api/v2/extensions"))
{
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
//var result = JsonConvert.DeserializeAnonymousType<>(content);
return true;
}
else
throw new Exception(response.ReasonPhrase);
}
}