How can I get the request payload? #146
Replies: 1 comment 1 reply
-
In v4.x and lower, I would read this as a string into the Payload property, but this was problematic for the same reason that it would be problematic to read the v5.x doesn't have a better solution for this currently. If you need the payload to be available during multiple routes, I would recommend deserializing it and adding to the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
IHttpContext context.Request.Payload was available in 4.2 version.
But it seems to have been removed.
How do I go about getting the request payload?
I tried this code below. Sometimes it works. Sometimes it doesn't return any data (even when the content-length is greater than 0.
using var reader = new StreamReader(context.Request.InputStream, context.Request.ContentEncoding);
var payload = await reader.ReadToEndAsync();
Beta Was this translation helpful? Give feedback.
All reactions