You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working with a .NET 8 API and have encountered an issue when sending a POST request to an unknown route. Here are the details:
When I send a POST request to an OData route that doesn't exist, e.g., {{apiUrlOData}}/Locationsdd, I receive a 405 Method Not Allowed response.
However, when I send the same request to a regular REST API route that doesn't exist, e.g., {{apiUrl}}/Locationsdd, I receive a 404 Not Found response.
This difference in behavior is unexpected. It seems that OData routing might be interpreting the route in a way that leads to the 405 response instead of a 404.
Is this difference in handling unknown routes between OData and REST in .NET 8 expected? Could you please clarify why OData returns a 405 error instead of a 404, and if there is a recommended way to align these behaviors?
Request/Response
POST request to an OData route that doesn't exist, e.g., {{apiUrlOData}}/Locationsjjjjjjjj
@KavehRostami90 What do you mean about "non-existed" OData route? Basically, OData route (endpoint) in 8.x is a normal ASP.NET Core endpoint containing 'OData routing metadata'. If it's an unknown route, why do you call its unknown OData route?
Would you please share a simple repro for us to dig more? Maybe a simple github repo can help us to figure out the root cause.
Assemblies affected
ASP.NET Core OData 8.2.5
Describe the bug
Hello,
I am working with a .NET 8 API and have encountered an issue when sending a POST request to an unknown route. Here are the details:
This difference in behavior is unexpected. It seems that OData routing might be interpreting the route in a way that leads to the 405 response instead of a 404.
Is this difference in handling unknown routes between OData and REST in .NET 8 expected? Could you please clarify why OData returns a 405 error instead of a 404, and if there is a recommended way to align these behaviors?
Request/Response
POST request to an OData route that doesn't exist, e.g., {{apiUrlOData}}/Locationsjjjjjjjj
{
"title": "Method Not Allowed",
"status": 405,
}
Expected behavior
{
"title": "Not Found",
"status": 404,
}
The text was updated successfully, but these errors were encountered: