Skip to content

RequestBody is Empty in Logged Request #35

Open
@craigeddy

Description

@craigeddy

Describe the bug

Using the following to configure APItoolkit in my .Net 8 ASP.NET Core API, I do not get anything in the endpoint logs' RequestBody. ResponseBody has expected values:

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
...
...
            // Initialize the APItoolkit client
            var config = new Config
            {
                ApiKey = "<API KEY>",
                Debug = false,
                Tags = ["external_api"],
                ServiceVersion = "v2.0",
                RedactResponseBody = ["$.ownerEmail"],
                RedactRequestBody =  ["$.ownerEmail"]
            };
            
            var client = APIToolkit.NewClientAsync(config).Result;
            // END Initialize the APItoolkit client
            
            // Register the middleware to use the initialized client
            app.Use(async (context, next) =>
            {
                // added this line based on searching for issue, didn't help:
                context.Request.EnableBuffering();

                var apiToolkit = new APIToolkit(next, client);
                await apiToolkit.InvokeAsync(context);
            });           
            
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
...

To Reproduce

No response

System

Windows 11 (have not tried deployed to Azure App Service yet)

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions