Restsharp使用openfire休息服务

时间:2015-11-20 14:30:40

标签: rest json.net openfire restsharp

首先我创建像

这样的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#代码中我得到这个错误 enter image description here

1 个答案:

答案 0 :(得分:0)

您不需要:

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

如果你有:

request.RequestFormat = DataFormat.Json;