• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • (Plesk for Windows):
    MySQL Connector/ODBC 3.51, 5.1, and 5.3 are no longer shipped with Plesk because they have reached end of life. MariaDB Connector/ODBC 64-bit 3.2.4 is now used instead.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Resolved 415 Unsupported Media Type

desaPax

New Pleskian
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

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);
}
}
 
Yes, I've seen that post, but that's not my case. In fact, I already send the application/json mime type in the calls.
Also, other calls such as listing the extensions in the /api/v2/extensions panel work perfectly.
Only the one that allows me to install SSL using LetsEncryp fails.
 
I've solved it now. It seems that you now have to indicate the data type in the string that is sent when making the request.

//NO WORKING
StringContent cont = new StringContent(JsonConvert.SerializeObject(ls));

//WORKS
StringContent cont = new StringContent(JsonConvert.SerializeObject(ls), Encoding.UTF8,"application/json");
 
Back
Top