【问题标题】:Google Calendar Push Notification谷歌日历推送通知
【发布时间】: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-notification httpresponse webhooks google-calendar-api


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-07
    • 1970-01-01
    • 2016-01-17
    • 2017-07-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多