Dear Team, I have been able to test some of the functionalities of the RingCentral system and I am fine with it.
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; } }
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.
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