Submitting a form to an OAP OAP controller for WebAPI using the Untyped model

I have an untyped model in my edm, defined like this:

<EntityType Name="Content">
  <Key>
    <PropertyRef Name="Id"/>
  </Key>
  <Property Name="Id" Type="Edm.Guid"/>
  <Property Name="Title" Type="Edm.String"/>
</EntityType>

      

When I try to submit a request from an html form, the IEdmEntityObject in my POST action is NULL.

public HttpResponseMessage Post(IEdmEntityObject entity)

      

This works fine with json - the object is populated with properties, but the odata deserializer doesn't seem to understand the application / x-www-form-urlencoded mimetype

<form method="POST" action="http://localhost/api/odata/content">
    Title:<br>
    <input type="text" name="Title" value="Mouse">
    <br>
    <input type="submit" value="Submit">
</form> 

      

+3


source to share


1 answer


Yes, WebApi OData does not support this format, you can check the code https://github.com/OData/WebApi/blob/master/OData/src/System.Web.OData/OData/Formatter/ODataMediaTypeFormatters.cs and the http spec : //docs.oasis-open.org/odata/odata-json-format/v4.0/odata-json-format-v4.0.html



Or you can customize the formatter, it might be tricky, but any other question or request can open the issue on github https://github.com/OData/WebApi

+1


source







All Articles