Problem: unable to capture payload from notifications
Platform: ASP.NET
Successfully execute the following code and webhook was created.
public static async Task Main(string[] args) { try { var rc = new RestClient(RINGCENTRAL_CLIENT_ID, RINGCENTRAL_CLIENT_SECRET); await rc.Authorize(RINGCENTRAL_USERNAME, RINGCENTRAL_EXTENSION, RINGCENTRAL_PASSWORD); await rc.Restapi().Subscription().Post(new CreateSubscriptionRequest { eventFilters = new[] { "/restapi/v1.0/account/~/extension/~/message-store" }, deliveryMode = new NotificationDeliveryModeRequest { transportType = "WebHook", address = DELIVERY_ADDRESS } }); Console.WriteLine("WebHook ready!"); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.Read(); }
Expected to capture (not exact, but similar) payload
{ "timestamp": "2018-10-07T12:05:00.408+0000", "uuid": "b11c9430-9687-4498-b12b-3fcb470bfe04", "event": "/restapi/v1.0/account/230919004/extension/230919004/message-store", "subscriptionId": "9d38419f-645f-4ee3-a053-8cf1368c21c4", "body": { "extensionId": 230919004, "lastUpdated": "2018-10-07T12:05:00.531+0000", "changes": [ { "type": "Fax", "updatedCount": 0, "newCount": 1 } ] }}
I am using the following code to handle both subscription creation and payload handling.
public void ProcessRequest(HttpContext context) { string headers = string.Empty; foreach (var key in context.Request.Headers.AllKeys) { headers += key + "=" + context.Request.Headers[key] + Environment.NewLine; } context.Response.Write(context.Request.RequestType + " == " + headers); if (context.Request.Headers["Validation-Token"] != null) context.Response.Headers.Add("Validation-Token", context.Request.Headers["Validation-Token"]); using (StreamReader reader = new StreamReader(context.Request.InputStream)) { context.Response.Write(reader.ReadToEnd() } context.Response.Write(context.Request); }
Can some please help on this matter?