0
votes

I am using the Google Calendar API with the .NET library. i am already able to create a channel between my project and the Google Calendar Push notification. i am setting up a working Webhook address. i am able too to read the header

[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 "";
    }

now i try to read the body. but nothing works. i already tried

  var test = HttpContext.Current.Request.InputStream;
  var sr = new StreamReader(test);
  string documentContents = sr.ReadToEnd();

or

                    using (Stream receiveStream = HttpContext.Current.Request.InputStream)
                {
                    using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8))
                    {
                        documentContents = readStream.ReadToEnd();
                    }
                }

But it did not work. And i could not find any examples or documentation. Hope that any body can help me. thank you in advance guys

1
Have you checked the Push Notifications full setup instructions? - noogui

1 Answers

0
votes

There is no body in the request. You can use X-Goog-Channel-ID in the META as the identifier. You can find more info in the Headerssection of the following link. https://developers.google.com/google-apps/calendar/v3/push