Skip to content

odata.context doesn't include group prefix #2873

Open

Description

@MFernando-MSFT

I'm configuring OData inside of a group prefix
configure.MapGroup("/mygroup").MapODataRoute("routename", "routeprefix", ...)

With that I can call the API on
https://example.com/mygroup/routeprefix/etcs('...')

but the result I get has the field @odata.context with:
https://example.com/routeprefix/#metadata#etcs/$entity

instead of
https://example.com/mygroup/routeprefix/#metadata#etcs/$entity

In other words, the prefix I created with MapGroup (/mygroup) isn't present on the odata.context response.

I'm using OData 7.7.7

Activity

  1. marabooy commented on Apr 8, 2025

    @marabooy
    Member

    Seems like MapGroup found in EndpointRouteBuilderExtensions injects a RouteGroupBuider .
    However the code below has a feature gap since the code was meant to work with a much Older version of Net core.

    Action<IContainerBuilder> builderAction = ConfigureDefaultServices(builder, configureAction);
    IServiceProvider subServiceProvider = perRouteContainer.CreateODataRootContainer(routeName, builderAction);
    // Resolve the path handler and set URI resolver to it.
    IODataPathHandler pathHandler = subServiceProvider.GetRequiredService<IODataPathHandler>();

  2. self-assigned this
    on Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions