这段代码应该给我 JsonString 作为回应。但我收到一个错误
System.dll 中出现“System.Net.WebException”类型的未处理异常
附加信息:远程服务器返回错误:(415)不支持的媒体类型。
string Url = "https://abc.test.xyz.com/123456344589753/transactions";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
string certThumbPrint = "ce03c469fb6c6dewwwww21886b7c1d405d954hshgd";
X509Certificate2 cert = FindCertificateByThumbprint(certThumbPrint);
if (cert != null)
{
request.ClientCertificates.Add(cert);
}
request.Method = "GET";
request.MediaType = "application/json";
request.ContentType = "application/json; charset=utf-8";
string text;
var response = (HttpWebResponse)request.GetResponse();
using (var sr = new StreamReader(response.GetResponseStream()))
{
text = sr.ReadToEnd();
}
解决此错误的任何建议