Skip to content

Conversation

@xuzhg
Copy link
Member

@xuzhg xuzhg commented Aug 13, 2025

Enable $batch request with minimal API

/// </summary>
public class ODataMiniBatchMiddleware
{
internal const string MinimalApiMetadataKey = "MS_MinimalApiMetadataKey_386F76A4-5E7C-4B4D-8A20-261A23C3DD9A";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this key used for? Is it specific for minimal API?
Can I use another value other than the one you have provided?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's only for minimal API scenario only. It's a key to save the metadata into HttpContext.Items and retrieve it from the HttpContext is it's OData $batch request.

request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json"));
HttpContent content = new StringContent(@"
{
""requests"": [{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add for methods POST and PATCH

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$batch is only for POST request.

@WanjohiSammy
Copy link
Member

/AzurePipelines run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@xuzhg xuzhg merged commit 7d7531c into main Aug 14, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants