Google日历推送通知

时间:2017-11-06 13:11:13

标签: push-notification httpresponse webhooks google-calendar-api

我正在使用带有.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();
                    }
                }

但它没有用。我找不到任何示例或文档。 希望任何身体都可以帮助我。提前谢谢你们

1 个答案:

答案 0 :(得分:0)

请求中没有正文。您可以使用X-Goog-Channel-ID中的META作为标识符。您可以在以下链接的Headers部分中找到更多信息。 https://developers.google.com/google-apps/calendar/v3/push

相关问题