我的代码是:
[WebInvoke(ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml, UriTemplate = "InsertUser", Method = "POST")]
public int InsertUser(Sales_Data instance)
{
using (DataEntities cxt = new DataEntities())
{
Sales_Data visitor = new Sales_Data();
visitor.fname = instance.fname;
visitor.email = instance.email;
visitor.phone = instance.phone;
cxt.AddToSales_Data(visitor);
cxt.SaveChanges();
return visitor.ID;
}
}
请求输入:
<Sales_Data>
<fname>ff</fname>
<email>ggg</email>
<phone>4444</phone>
</Sales_Data>
然后在休息客户端测试时,我收到400 Bad Request。
请求输入中是否有任何错误。