Trouble creating a Webhook with API in C#

  • 1
  • Problem
  • Updated 1 month ago
I am trying to create a Webhook to be notified when a message is sent back to my account that I use for my server app. I initially send out messages and the final goal is functionality for when they reply for my app to be able to trigger another message to be sent.

I am using a password flow for authorization because this is a server app with no UI. I make a CreateSubscriptionRequest object for the request of the POST and give it eventFilters and a NotificationDeliveryModeRequest object with transportType and address. I then navigate to the subscription endpoint where I call the POST method with the CreateSubscriptionRequest object as its parameter and when the code gets to this point it returns an error saying "Call failed with status code 400 (Bad Request) POST https://platform.devtest.ringcentral.com/restapi/v1.0/subscription".

I'm not sure what the problem with the request is or if its something else that I cant figure out. If anyone has any ideas or the same issue please let me know. Thanks!
Photo of Cole Bennington

Cole Bennington

  • 82 Points 75 badge 2x thumb

Posted 1 month ago

  • 1
Photo of Tyler Long

Tyler Long, Official Rep

  • 7,802 Points 5k badge 2x thumb
Are you using https://github.com/ringcentral/ringcentral-csharp-client#exception-handling  ?

You can catch the exception and print the error response:

string errorMessage = fhe.GetResponseString(); 
Console.WriteLine(errorMessage);
Photo of Cole Bennington

Cole Bennington

  • 82 Points 75 badge 2x thumb
Thank you for your timely response. This is the error I seem to be getting

{"errorCode":"SUB-525","message":"WebHook server response is invalid","errors":[{"errorCode":"SUB-525","message":"WebHook server response is invalid"}]}
Photo of Tyler Long

Tyler Long, Official Rep

  • 7,802 Points 5k badge 2x thumb
https://ringcentral-quickstart.readthedocs.io/en/latest/webhooks/

  1. is available on the Internet
  2. has a TLS / SSL enabled*
  3. can respond within 1000 milliseconds
  4. will respond with Validation-Token header on subscription

It might because the WebHook server doesn't respond with HTTP status code 200. Please check the log on your WebHook server.