Kushal Chokhani
Kushal Chokhani

Reputation: 33

Not able to create calendar events webhook

I am trying to create a subscription for calendar events. But I am getting 400 error with message containing:

    "code": "InvalidRequest",
    "message": "Subscription validation request failed. Must respond with 200 OK to this request."

As per webhook validation doc my server should have received call on notificationUrl passed in subscription post body, which is not happening for some reason. I can confirm this same POST notificationUrl could be accessed by me and it accepts validationToken as query param.

Can someone please help here.

Upvotes: 0

Views: 125

Answers (2)

Kushal Chokhani
Kushal Chokhani

Reputation: 33

Managed to resolve after checking access logs. Validationtoken request was getting blocked with 415 error because my api was only accepting json. Ensured that it can also accept "text/plain" and it is now working.

Upvotes: 1

DevÁsith
DevÁsith

Reputation: 1234

your service must respond to this validation request by returning the value of the validationtoken query string parameter as a plain-text response.

something like

[HttpPost]
        public async Task<ActionResult> Listen()
        {

            if (Request.QueryString["validationToken"] != null)
            {
                var token = Request.QueryString["validationToken"];
                return Content(token, "plain/text");
            }
}

Upvotes: 2

Related Questions