• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

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