【问题标题】:Posting to server via C# with RestSharp使用 RestSharp 通过 C# 发布到服务器
【发布时间】:2015-03-14 01:36:35
【问题描述】:

我整晚都在尝试在 c# 中获得以下 REST 响应。网址是

http://domain/WebServices/api/AdvisingApi/Authenticate?flashlineID=jdister1&password=password

我使用了一个名为 https://www.hurl.it/ 的站点来确保该端点正在运行,它可以让我得到预期的响应。但是,在我的 C# 代码中,我不断得到一个

"{\"消息\":\"发生错误。\"}"

作为我 RestSharp 请求中的响应。以下是相关代码:

var client = new RestClient("http://domain/WebServices/api/AdvisingApi/");
        var request = new RestRequest("Authenticate", Method.POST);
        request.RequestFormat = DataFormat.Json;
        request.AddParameter("flashlineID", userName);
        request.AddParameter("password", password);

        IRestResponse response = client.Execute(request);

我不确定自己做错了什么,因为我以与 Hurl.it 发送的相同方式(我认为)构建请求。有什么建议么?谢谢!!

【问题讨论】:

    标签: c# asp.net post restsharp


    【解决方案1】:

    抱歉,我提出了愚蠢的问题和糟糕的研究。联系了供应商,发现预期的类型是 xml。

    【讨论】:

      猜你喜欢
      • 2021-10-01
      • 2012-03-03
      • 1970-01-01
      • 2020-03-21
      • 2016-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多