question: how to get raw request body
See original GitHub issueI’m adding a Stripe webhook and I need to get raw request body, like:
app.post('/webhook', bodyParser.raw({type: 'application/json'}), (request, response) => {}
https://stripe.com/docs/webhooks/signatures#verify-official-libraries
How I can get it using routing-controller?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7 (1 by maintainers)
Top Results From Across the Web
How do I get the raw request body from the Request.Content ...
You can get the raw data by calling ReadAsStringAsAsync on the Request.Content property.
Read more >How to get RAW request body in anonymous web service?
I want to get the full raw request body inside a POST method. Is there any way to do it since it's not...
Read more >Reading the raw request body as a string in ASP.NET Core
In the .NET Framework version of MVC, this is simple. You first reset the position of the stream, then re-read it: Request.InputStream ...
Read more >Raw request body - HTTPie 3.2.1 (latest) docs
There are three methods for passing raw request data: piping via stdin , --raw='data' , and @/file/path . Redirected Input. The universal method...
Read more >Get raw request body in custom controller - Strapi Backend
const raw = ctx.request.body[Symbol.for("unparsedBody")];. Home · Categories ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Spent all afternoon trying to figure this out too, but I have a solution:
Add the following middleware:
In your controller, add the middleware to the endpoint that requires a raw body and access the raw body property from the request using the
@Req()
decorator:Hope that helps!
I tried the solution above, but stripe wasn’t liking the rawBody buffer, just passing the bodyparser.raw function into the UseBefore decorator seems to work for me!