Skip to content

RequestBody is Empty in Logged Request #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
craigeddy opened this issue Sep 2, 2024 · 7 comments
Open

RequestBody is Empty in Logged Request #35

craigeddy opened this issue Sep 2, 2024 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@craigeddy
Copy link

craigeddy commented Sep 2, 2024

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

@craigeddy craigeddy added the bug Something isn't working label Sep 2, 2024
@dawkaka
Copy link
Contributor

dawkaka commented Sep 2, 2024

@craigeddy Thank you for taking the time to open this issue and providing detailed information. I'm looking into the problem you're experiencing with the RequestBody and I'll notify you when a new version is released.

@dawkaka
Copy link
Contributor

dawkaka commented Sep 2, 2024

@craigeddy A new version has been released (1.0.7) that addresses the missing request body issue, thank you.

@craigeddy
Copy link
Author

@dawkaka Unfortunately, I am still experiencing this issue, even with 1.0.7.

@dawkaka
Copy link
Contributor

dawkaka commented Sep 3, 2024

@craigeddy So sorry about that, there was an issue with the build, version 1.0.8 has been released which should address the problem, let me know if you run into any issues.

@craigeddy
Copy link
Author

@dawkaka still not working.

For reference, my controller method is defined with

        [HttpPost]
        [SwaggerOperation("Create a new subject")]
        [Authorize(Policy = Policies.ManageSubjects)]
        // ReSharper disable once CognitiveComplexity
        public async Task<IActionResult> AddSubject([FromBody] NewSubject newSubject)

@tonyalaribe
Copy link
Contributor

Hi Craig,

I'm unable to reproduce the issue any longer with the latest release. Did you give it a try?

@craigeddy
Copy link
Author

@tonyalaribe @dawkaka It is working now (I swear I tried after putting 1.0.8 in place and it was not, but who knows).

I have noticed another issue, though:

Every Boolean property in both the request body and the response body shows as true regardless of the value in either the request or the response. Would you like me to open another issue with details?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants