This OData function does not deserialize the model parameter from the body. It deserializes as null
as seen from response. Is there support for FromBody parameters in OData V4?
ConfigV1.cs
builder.Function("CreateTestModel").Returns<TestModel>();
var edmModel = builder.GetEdmModel()
config.MapODataServiceRoute("ODataRouteV1", "v1", edmModel);
TestController.cs
using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.OData;
using System.Web.OData.Query;
using System.Web.OData.Routing;
public class TestController : ODataController
[HttpPost]
[ODataRoute("CreateTestModel")]
public TestModel CreateTestModel([FromBody]TestModel model)
{
return model;
}
}
TestModel.cs
public class TestModel
{
public string Value { get; set; }
}
Request
POST /v1/CreateTestModel HTTP/1.1
Host: localhost:8090
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 4810cdc0-d92b-b7b5-4328-8b87e0222854
{
"Value": "test"
}
Response
{
"@odata.context":"http://localhost:8090/V1/$metadata#Edm.Null","@odata.null":true
}