zoukankan      html  css  js  c++  java
  • "远程服务器返回错误: (500) 内部服务器错误"错误处理

    公司购买的百傲瑞达一卡通软件,提供Restful API调用,使用SoapUI能够调用成功,但在C#里用代码调用时一直报错:"远程服务器返回错误: (500) 内部服务器错误"

    找了很久,最后发现是需要设置UserAgent,在SoapUI里面找到成功调用时显示的User-Agent,再在代码里加上一句给Request赋UserAgent的语句即可。

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    request.Method = "GET";
    request.UserAgent = "Apache-HttpClient/4.1.1 (java 1.5)";
    request.ContentType = "application/json;charset=UTF-8";
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    

      

  • 相关阅读:
    学习进度条64
    学习进度条63
    学习进度条62
    学习进度条61
    学习进度条60
    学习进度条59
    学习进度条58
    学习进度条57
    学习进度条56
    学习进度条55
  • 原文地址:https://www.cnblogs.com/dimg/p/10199181.html
Copyright © 2011-2022 走看看