我有這樣的控制器:的Web API的OData 2 V4 PATCH返回404
using System.Web.Http;
using System.Web.OData;
public class InvRecipientAutoInvoiceController : ODataController
{
// GET: odata/InvRecipientAutoInvoice
[EnableQuery]
public IQueryable<Inv_RecipientAutoInvoice> GetInvRecipientAutoInvoice()
{
return db.Inv_RecipientAutoInvoice.Where(a=>a.CompanyNumber == CompanyNumber);
}
[AcceptVerbs("PATCH", "MERGE")]
public IHttpActionResult Patch([FromODataUri] int RecipientNumber , [FromODataUri] int RecipientType, Delta<Inv_RecipientAutoInvoice> patch)
{
// XXXX Some Update Code
}
}
的GET作品,我得到的結果,甚至可以對其進行排序。 但是當我做修補請求,我得到404錯誤, 補丁請求:
請求URL:http://localhost:61240/odata/InvRecipientAutoInvoice(RecipientNumber%3D443%2CRecipientType%3D400)
Request Method: PATCH
- 響應體:
{「錯誤「:{ 」code「:」「,」message「:」沒有找到與請求URI匹配的HTTP資源 'http://localhost:61240/odata/InvRecipientAutoInvoice(RecipientNumber=443,RecipientType=400)'。「,」innererror「:{ 」message「:」在控制器'InvRecipientAutoInvoice'上找不到與 請求相匹配的操作。「,」type「:」「,」stacktrace「:」「 }} }
- 請求正文:
{"InvoiceLine1Description":"32132"}
我使用它在ASP.net web項目(不MVC),
寄存器是:
config.MapODataServiceRoute(
routeName: "ODataRoute",
routePrefix: "odata",
model: builder.GetEdmModel());
我失去了什麼?