AJAX请求:
$.ajax({
url: url,
dataType: 'json',
type: 'Post',
data: {token:"4", feed:{"id":0,"message":"Hello World","userId":4} }
});
服务器端 Web API:
[HttpPost]
public HttpResponseMessage Post(string token, Feed feed)
{
/* Some code */
return new HttpResponseMessage(HttpStatusCode.Created);
}
错误代码404: {"message":"找不到匹配请求URI“localhost:8080/api/feed”的HTTP资源。","messageDetail":"在控制器'Feed'上没有找到与请求相匹配的操作。"}
我为什么会遇到这个错误,为什么我不能将多个参数POST到我的API?
feed
,但方法名是post
? - Christian Phillipsfeed/
前加上斜线吗? - Christian Phillips