【问题标题】:Restsharp using with openfire rest serviceRestsharp 与 openfire 休息服务一起使用
【发布时间】:2016-02-23 02:07:11
【问题描述】:

首先我创建像这样的 json 服务

RootObject ro = new RootObject ();
        ro.username = "halukmy";
        ro.password = "1234";

比我创建我的休息帖

var client = new RestClient ("https://84.84.83.82:9091" +
                         "/plugins/restapi/v1/users");
            client.Authenticator = new SimpleAuthenticator ("username", "haluk", "password", "123456789");
            var request = new RestRequest ("resource", Method.POST);
            request.AddHeader ("Accept", "application/json");
            request.RequestFormat = DataFormat.Json;



            request.AddBody (new RootObject {

                username = "ffff" +
                "",
                password = "1234"
            });

            client.Execute (request);

但是我得到了标题错误?当我在浏览器上使用时没问题,但在 c# 代码中我收到此错误

【问题讨论】:

  • 你能用你收到的错误更新你的问题吗?
  • ErrorMessage "Error: SendFailure (Error writing headers)" 字符串
  • s21.postimg.org/6f8pdr4t3/… 这是完整的问题
  • 请在下方查看我的回答

标签: rest json.net openfire restsharp


【解决方案1】:

你不需要:

request.AddHeader ("Accept", "application/json");

如果你有:

request.RequestFormat = DataFormat.Json;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-28
    • 2013-10-25
    • 1970-01-01
    • 1970-01-01
    • 2016-04-02
    • 1970-01-01
    相关资源
    最近更新 更多