Rest客户端post请求工作在邮差,但不是在c#代码


using System; 
using System.Collections.Generic; 
using System.Linq;
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using RestSharp; 
using System.Diagnostics;
namespace mobile_link_account 
{
public partial class update_mobile_link_ngb : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
var client = new RestClient("https://xyz.apcz.in/appkvvcl/ngb/backend/api/v1/authentication/login");

var request = new RestRequest(Method.POST);
request.AddHeader("Postman-Token", "e8a9e567-f7e6-4820-9096-a0aef2c2b003");
request.AddHeader("cache-control", "no-cache");

request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", "{n    "username": "xyz",n    "password": "xys"n}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
for (int i = 0; i < response.Headers.Count; i++)
{
Debug.WriteLine("***************" + response.Headers[i]);
}
Debug.WriteLine("" + response.StatusCode);
}
}
}

输出标题:

*************** x-content-type-options = nosniff*************** x-xss-protection = 1;模式=块*************** 编译指示= no - cache*************** x-frame-options =否认*************** 不同=接受编码*************** 内容编码=*************** 传输编码=分块*************** 连接=近*************** cache - control: no - cache,不是商店,信息= 0,must-revalidate*************** application/json - type =; charset = utf - 8***************日期=星期二,2021年10月26日11:17:38 GMT*************** 到期= 0*************** X-Powered-By =表达InternalServerError

如果是内部服务器错误,例如500,那么用断点调试该方法并告诉我们发生了什么

相关内容

  • 没有找到相关文章

最新更新