-
Notifications
You must be signed in to change notification settings - Fork 98
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
HttpRequestMessage does not have data in ASP.NET Core #34
Comments
Check this out. |
I got same issue, but i rewrite the using(var reader = new StreamReader(httpContext.Request.Body))
{
var content = await reader.ReadToEndAsync();
...
...
dynamic json = JsonConvert.DeserializeObject(content);
} |
Using seanmars' code to create a method like the one below, I was able to create an HttpRequestMessage that the "GetWebhookEventsAsync" extension method can use successfully. Note that the "X-Line Signature" key must be included in the header. private async Task<HttpRequestMessage> GetLineRequest()
{
using (var reader = new StreamReader(HttpContext.Request.Body))
{
var content = await reader.ReadToEndAsync();
var reqMessage = new HttpRequestMessage
{
RequestUri = new Uri("https://localhost:5001/callback"),
Content = new StringContent(content, Encoding.UTF8, "application/json")
};
var signature = HttpContext.Request.Headers.Where(x => x.Key == "X-Line-Signature").First();
reqMessage.Headers.Add(signature.Key, signature.Value.ToString());
return reqMessage;
}
} |
Currently I am converting LINE with bot framework application to ASP.NET Core, implement the same controller
[HttpPost] public async Task<ActionResult> Post([FromBody] HttpRequestMessage request)
But when I test webhook, HttpRequestMessage does not have any data. Can anyone help?
The text was updated successfully, but these errors were encountered: