'How do I configure OData to use a POST with /$query on an endpoint configured with ODataAttributeRouting? I'm getting a 404
This is a follow-up to OData AspNetCore support for long URLs useing $query is not working.
OData 8.0.4
In startup, I have app.UseODataQueryRequest()
My Controller looks like
[ODataAttributeRouting]
public class ODataQueryController : Controller
{
[HttpGet] // not needed, it turns out
[EnableQuery]
[Route("Thing")]
public IActionResult GetThings()
{
return Ok(ApplicationContext.Things);
}
}
and my POST looks like
POST http://localhost:8080/api/odata/Thing/$query
Request Body: $select=Column
Content-Type: text/plain
and I get a 404
Solution 1:[1]
Placing app.UseODataQueryRequest()
before app.UseRouting()
resolved this issue for me
Startup.cs:
...
app.UseODataQueryRequest();
...
app.UseRouting();
...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |