我想在spreadshirt上验证我,但结果却出现内部服务器错误。
我是Rest API的新手..
以下是文档:https://developer.spreadshirt.net/display/API/Security+Resources
和我的代码:
var client = new RestClient("https://api.spreadshirt.net/api/v1");
var request = new RestRequest("sessions", Method.POST);
request.AddParameter("username", "foo");
request.AddParameter("password", "bar");
var test = client.Execute(request);
编辑:
搞定了
我的登录类
[SerializeAs(Name ="login")]
public class Login
{
private string user;
private string pw;
[SerializeAs(Name ="username")]
public string username
{
get
{
return "foo";
}
set
{
this.user = value;
}
}
[SerializeAs(Name ="password")]
public string password
{
get { return "bar"; }
set { this.pw = value; }
}
}
按钮单击
var login = new Login();
var request = new RestRequest("sessions/", Method.POST);
var client = new RestClient("https://api.spreadshirt.net/api/v1/");
request.XmlSerializer = new RestSharp.Serializers.XmlSerializer();
request.RequestFormat = DataFormat.Xml;
request.AddXmlBody(login, "http://api.spreadshirt.net");
var response = client.Execute(request);
MessageBox.Show(response.StatusCode.ToString());