Skip to content

Net core odata with versioning and template in url prefix #529

Closed
@rakkum

Description

@rakkum

Hello,
it might be a stupid question but I coudn't find anything in the documentation about it.
The idea is to pass a tenantId in the URL and process that in a ODataController to select the current tenant. It should not be part of the odata query so I wanted to have it in such a setup.

I have a route setup like this
routes.MapVersionedODataRoutes("odata-bypath", "api/v{version:apiVersion}/tenants/{tenantId}", models);
and a controller such as

[ODataRoutePrefix("WorkItemSearch")]
  public class ODataWorkItemSearchController :
      ODataController
  {
      public ODataWorkItemSearchController(MyDbContext context)
      {
           this.context = context;
      }

      private MyDbContext context;

      [EnableQuery]
      public IQueryable<ODataWorkItemSnapshot> Get(Guid tenantId)
      {
          return search.Snapshots.Where(x => x.TenantId == tenantId);
      }
}

When accessing api/v1/tenants/00000000-0000-0000-0000-000000000001 i get the odata context as expected.
However, when accessing api/v1/tenants/00000000-0000-0000-0000-000000000001/WorkItemSearch i get a 404.
I also tried /api/v1/tenants/00000000-0000-0000-0000-000000000001/WorkItemSearch/00000000-0000-0000-0000-000000000001 just to make sure but there I get the same 404 response.
Swagger reports api/v1/tenants/{tenantId} as the path to the controller so I don't know what is going wrong.

Any ideas?

Thanks,
Klemens

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions