我有一个OData服务,我想向它发送一个Json对象。但我不明白!
这是我的代码:
在MVC控制器中
public class SyncController : ODataController
{
[HttpPost]
public IQueryable<AppWriteError> GetSync(AppSyncDataModel data)
{
// do some stuff
}
}
这是AppSyncDataModel
:
public class AppSyncDataModel
{
public Guid UserId { get; set; }
}
这是我的ajax电话:
$.ajax({
url: url,
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(synchData) ,
success: function () {
alert("success :-)");
},
error: function () {
alert("fail :-(");
}
因此,如果我运行它,AppSynchDataModel
始终为null,我收到以下消息:
{
"odata.error":{
"code":"","message":{
"lang":"en-US","value":"No HTTP resource was found that matches the request URI 'http://localhost:3367/odata/Sync'."
},"innererror":{
"message":"No routing convention was found to select an action for the OData path with template '~/entityset'.","type":"","stacktrace":""
}
}
}
我该怎么做?