ardalis / ApiEndpoints

A project for supporting API Endpoints in ASP.NET Core web applications.
MIT License
3.13k stars 227 forks source link

Cant read the request body using StreamReader #183

Open negrifelipe opened 2 years ago

negrifelipe commented 2 years ago

Steps to Reproduce:

  1. Create a post endpoint without request and without result
  2. Try to read the request body using StreamReader

Here is my full code: https://github.com/negrifelipe/Payments/blob/f74c37141bdf402774b42bc183bcbad538d8c243/src/Payments.Providers.PayPal/Endpoints/NotifyEndpointAsync.cs#L38 using a normal controller solved the issue

ardalis commented 2 years ago

What error did you get?

negrifelipe commented 2 years ago

I got an empty string

negrifelipe commented 2 years ago

Maybe its something related to controllers because the endpoint is still a controller the only thing that changes is that the endpoint inherits a class that its a controller

ardalis commented 2 years ago

Can you post your working code? I have no idea why a vanilla controller would work and the inherited controller used by this package wouldn't. Thanks!

negrifelipe commented 2 years ago

Working code: https://github.com/negrifelipe/Payments/blob/2e7d866160ade93cc17c13aafa71942d8c97b94c/src/Payments.Providers.PayPal/Controllers/PaypalController.cs#L35 Not working code: https://github.com/negrifelipe/Payments/blob/f74c37141bdf402774b42bc183bcbad538d8c243/src/Payments.Providers.PayPal/Endpoints/NotifyEndpointAsync.cs#L38