C# 使用post调用web服务器时出现内部服务器错误
获取返回json列表的post to api字符串时出错C# 使用post调用web服务器时出现内部服务器错误,c#,.net,api,console-application,C#,.net,Api,Console Application,获取返回json列表的post to api字符串时出错 string apiUrl = "https://expample.com/api.asmx/Agency_ListNewAndModifiedOrders"; var input = new { SecurityCode = "xxx123", LastModifiedMinutes = 60, ExcludePe
string apiUrl = "https://expample.com/api.asmx/Agency_ListNewAndModifiedOrders";
var input = new
{
SecurityCode = "xxx123",
LastModifiedMinutes = 60,
ExcludePerDiem = false,
ExcludeContracts = false,
ExcludePermPlacement = false
};
string inputJson = (new JavaScriptSerializer()).Serialize(input);
WebClient client = new WebClient();
client.Headers["Content-type"] = "application/json";
client.Encoding = Encoding.UTF8;
string json = client.UploadString(apiUrl, inputJson);
然后得到错误500
System.Net.WebException:“远程服务器返回了一个错误:500内部服务器错误。”这仅仅意味着您发送邮件的服务器中有一个错误。如果您有权访问服务器,您可以在那里进行调查或调试。正如消息所述,远程服务器上出现了错误,而不是代码中的错误。您的请求可能在某种程度上存在错误,但我们无法知道,因为我们没有维护远程服务器。如果响应中没有其他信息,您可能需要与维护该远程服务器的人员联系。