首先我创建像
这样的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);
答案 0 :(得分:0)
您不需要:
request.AddHeader ("Accept", "application/json");
如果你有:
request.RequestFormat = DataFormat.Json;