【发布时间】:2017-11-06 13:11:13
【问题描述】:
我正在使用带有 .NET 库的 Google Calendar API。 我已经能够在我的项目和 Google 日历推送通知之间创建一个频道。我正在设置一个有效的 Webhook 地址。 我也可以阅读标题
[System.Web.Mvc.HttpPost]
public string CalendarWebhook()
{
HttpContext ctx = HttpContext.Current;
if (ctx == null || ctx.Request == null || ctx.Request.Headers == null)
{
return string.Empty;
}
string headers = string.Empty;
foreach (string header in ctx.Request.Headers.AllKeys)
{
string[] values = ctx.Request.Headers.GetValues(header);
headers += string.Format("{0}: {1}", header, string.Join(",", values));
}
return "";
}
现在我尝试阅读正文。但没有任何效果。 我已经试过了
var test = HttpContext.Current.Request.InputStream;
var sr = new StreamReader(test);
string documentContents = sr.ReadToEnd();
或
using (Stream receiveStream = HttpContext.Current.Request.InputStream)
{
using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8))
{
documentContents = readStream.ReadToEnd();
}
}
但它没有工作。而且我找不到任何示例或文档。 希望任何机构都可以帮助我。提前谢谢你们
【问题讨论】:
-
您查看过Push Notifications 的完整设置说明吗?
标签: push-notification httpresponse webhooks google-calendar-api