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?
Hi Phong,
I followed the this like Webhook Notifications C# Quick Start to create a dotnet core app.
After running the setup_webhook, I received the following subscription info
{ "id": "6d926976-2db7-4963-8e92-3e18814800ca", "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/subscription/6d926976-2db7-4963-8e92-3e18814800ca", "eventFilters": [ "/restapi/v1.0/account/265370004/extension/265370004/message-store" ], "disabledFilters": null, "expirationTime": "2019-08-30T14:40:56.347Z", "expiresIn": 604799, "status": "Active", "creationTime": "2019-08-23T14:40:56.347Z", "deliveryMode": { "transportType": "WebHook", "encryption": false, "address": "http://dev.jsacalltracker.com/webhook/update_faxes.ashx", "subscriberKey": null, "secretKey": null, "encryptionAlgorithm": null, "encryptionKey": null }, "blacklistedData": null }
I then sent a few faxes using Create Fax Message. I don't see any subscriptions received by the previous code.
I want to know, how to handle the notifications sent by RingCentral when a new fax is received by my fax number.
I can't say what is wrong with your code. It's hard to trace w/o seeing the entire project and environment setup. But, please see this quick start for help.
A new Community is coming to RingCentral!
Posts are currently read-only as we transition into our new platform.We thank you for your patience
during this downtime.
Try Workflow Builder
Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!Try RingCentral Workflow Builder