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
Not Getting Webhook Notifications
Tags: webhooks, notifications
May 9, 2022 at 4:25pm   •   1 replies  •  0 likes
Jide Ola

Dear Team, I have been able to test some of the functionalities of the RingCentral system and I am fine with it.

However, i am still having some challenges with the webhook API.
I followed the instruction on the website to set up a web hook api for our proposed fax system.

However I am not receiving any notification on the web hook end point as expected. Please tell me what I am doing wrong. My web hook end point is called createsubscription(for you to kindly look up). Please see all my code snippets below

StartUp

app.Run((context) =>
{
  
context.Request.Headers.TryGetValue("Validation-Token", out StringValues validationToken);
context.Response.Headers.Add("Validation-Token", validationToken);
if (context.Request.Path == "/webhook" && context.Request.Method == "POST")
{
  
using (StreamReader reader = new StreamReader(context.Request.Body, Encoding.UTF8))
{
  
var str = reader.ReadToEndAsync();
Console.WriteLine(str);
}
}

return Task.CompletedTask;
});


//Program Class
public class Program
{
  
static RestClient restClient;
const string DELIVERY_ADDRESS = "https://e889-96-73-205-2.ngrok.io/ringcentral/hook";
public static void Main(string[] args)
{
  
Activity.DefaultIdFormat = ActivityIdFormat.W3C;
CreateHost(args);
subscription();


}
async static void subscription()
{
  
const string RECIPIENT = "+16079303426";
const string RINGCENTRAL_CLIENTID = "MJ9Ch2XRRm6xjTQXSsbRYA";
const string RINGCENTRAL_CLIENTSECRET = "254-Vxa_SBa_6JXDBja0Aw8R1dxS1URvxxxxxxxx";
const string RINGCENTRAL_SERVER = "https://platform.devtest.ringcentral.com";
const bool RINGCENTRAL_PRODUCTION = false;

const string RINGCENTRAL_USERNAME = "+1470xxxxyyyy";
const string RINGCENTRAL_PASSWORD = "pwd";
const string RINGCENTRAL_EXTENSION = "101";


restClient = new RestClient(
RINGCENTRAL_CLIENTID,
RINGCENTRAL_CLIENTSECRET,
RINGCENTRAL_SERVER);
restClient.Authorize(
RINGCENTRAL_USERNAME,
RINGCENTRAL_EXTENSION,
RINGCENTRAL_PASSWORD).Wait();
await restClient.Restapi().Subscription().Post(new CreateSubscriptionRequest
{
  
eventFilters = new[] { "/restapi/v1.0/account/312526004/extension/312526004/fax?direction=Inbound" },
deliveryMode = new NotificationDeliveryModeRequest
{
  
transportType = "WebHook",
address = DELIVERY_ADDRESS
}
});
Console.WriteLine("WebHook ready!");
}
}


public class RingCentralController : Controller
{
  
 //Web Hook End Point
[HttpPost]
[Route("hook")]
public ActionResult<HttpResponseMessage> createsubscription(CreateSubscriptionRequest createSubscriptionRequest)
{
  
string authtoken = createSubscriptionRequest.deliveryMode.verificationToken;
if (authtoken.Length > 0)
{
  
return BadRequest();
}

HttpResponseMessage responseMessage = new HttpResponseMessage();
responseMessage.Headers.Add("Validation-Token", authtoken);

return responseMessage;

}
}
1 Answer
answered on May 9, 2022 at 5:46pm  

First of all, here are some guidelines and best practices to get help.

1. NEVER post sensitive information about your app, user credentials in public forum (I already modified your post to hide them).

2. Post code within code block and correct indents for better readability.

3. Post some trace log so people can see what could happen at what point.


Check if you pass the line Console.WriteLine("WebHook ready!");?

Your defined path is "/ringcentral/hook" but you expect the "/webhook" path

if (context.Request.Path == "/webhook" && context.Request.Method == "POST")

You also have some extra code to define a different webhook endpoint. Why?

[HttpPost]
[Route("hook")]

Where do you get the instruction and the code from? I recommend to follow the code in this dev guide getting started.



 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