0

I have several Odata(4.0)/Rest controllers in my project(c#/.net 4.62). All but 1 work as expected. This is the controller that returns a 406 every time I call it.

[RoutePrefix("api/SecurityConfig")]
[ApiExplorerSettings(IgnoreApi = false)]
public class SecurityConfigController : ODataController
{

    [Route("GetRoleGroupWithRoles")]
    [EnableQuery(MaxExpansionDepth = 6)]
    [HttpGet]
    public virtual async Task<IHttpActionResult> GetRoleGroupWithRoles([FromODataUri] Guid key)
    {
        return Ok("Hello World");
    }
}

I call using the following headers:

Accept: application/* (though I've tried just "*" and "application/json")

Content-Type: application/json

I'm baffled why this controller is not working and the rest of them are......thanks in advance for any thoughts on how I can figure this out.

1

1 Answer 1

0

I think you are missing the first two steps of building an OData service. ODataController, as the name says, only works with OData routes. You need to build an EDM model representing your OData service, and, add an OData route exposing that EDM model. Refer to this official documentation and blog post for details on how to build OData services. [source]:How can I avoid a 406 when receiving an OData.PageResult<T>?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.