News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
[sandbox] unable to capture payload on server side.
Tags: rest api
Aug 23, 2019 at 6:44am   •   2 replies  •  0 likes
P B

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?

2 Answers
answered on Aug 23, 2019 at 8:04am  

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.


 0
answered on Aug 23, 2019 at 7:44am  

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.


 0



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

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us