我有我自己的休息API我在c#3.5 framewok中调用下面的代码,但这种方法不打电话请帮助我
var json = JsonConvert.SerializeObject(objproperties);
string url = "http://localhost:3423";
using (WebClient client = new WebClient())
{
responseData = client.UploadString(url+"api/json/Cardpayment", json);
}
我的REST API方法。
[System.Web.Http.AcceptVerbs("GET", "POST")]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public HttpResponseMessage Cardpayment(classProperties objproperties)
{
try
{
string myid = objproperties.myid;
}
}
答案 0 :(得分:0)
添加Header ..对我来说很好..
client.Headers.Add("API-Version: 5.0");
client.Headers.Add("Content-Type", "application/json");
responseData = client.UploadString(url+"api/json/Cardpayment", json);