Aabid Khan avatar image
Aabid Khan asked

How to handle validation token for webhook subscription in apex.

To handle validation token, I'm creating below code.


global class ringcentralWebhook {


global static String doPost() {

RestRequest req = RestContext.request;

RestResponse res = RestContext.response;

String JsonBody = req.requestBody.toString();

Map<String, Object> body = (Map<String, Object>)Json.deserializeUntyped(JsonBody);

String s = String.valueOf(body);

contact c = new contact(lastName = 'test ringcentral again', description=s);

insert c;

Map<String,Object> m = (Map<String,Object>)req.headers;

String vt1 = String.valueOf(m.get('Validation-token'));

String header = 'Validation-Token';

res.addHeader(header, vt1);

res.statusCode = 200;

return String.valueOf(res);



for callout from postman: -

In Header : -

Accept application/json

Authorization Bearer myToken

Content-Type application/json

For body (raw): -


"eventFilters": [



"deliveryMode": {

"transportType": "WebHook",

"address": ""




It through error : - "errorCode": "SUB-522", "message": "WebHook responds with incorrect HTTP status. HTTP status is 500", "status": "500"

If I'm wrong in any place please correct me.

rest api
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

0 Answers

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys