Skip to content

$batch returns 404 or 405 when using Asp.Versioning.OData.ApiExplorer 6.0.0-preview.3, OData 8 and .Net 6 #847

Closed
@joevanheerden

Description

@joevanheerden

I'm cannot figure out how to make Odata Batching to work when using API Versioing. I cannot tell if I'm missing configuration, or whether the issue is with Odata or API Versioning.

Using URL Segement versioning and the following configuration results in a 404 when making a GET request to api/v1/$batch, and 405 when making a POST request.

builder.Services.AddControllers().AddOData();
    builder.Services.AddApiVersioning(
            options =>
            {
                options.ApiVersionReader = new UrlSegmentApiVersionReader();
            })
        .AddOData(options =>
                  {
                      var defaultBatchHandler = new DefaultODataBatchHandler
                      {
                          MessageQuotas =
                          {
                              MaxNestingDepth = 2,
                              MaxOperationsPerChangeset = 10,
                              MaxReceivedMessageSize = 100
                          }
                      };

                      options.AddRouteComponents("api/v{version:apiVersion}", defaultBatchHandler);
                  });

...

app.UseHttpsRedirection();
app.UseAuthorization();
app.UseODataBatching();
app.MapControllers();
app.Run();

Expected behaviour is to get the expected OData response for POST, and 'The batch request must have a "Content-Type" header.' for GET.

Any help would be much appreciated.

Thanks to the author of this repo for all the hard work in maintaining this - the effort is much appreciated.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions