question

Aabid Khan avatar image
Aabid Khan asked Aabid Khan edited

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

While creating webhook from salesforce apex callout or from postman. I am getting same error everytime.

{

"eventFilters": [

"/restapi/v1.0/account/~/extension/~/message-store?type=SMS&direction=Inbound"

],

"deliveryMode": {

"transportType": "WebHook",

"address": "https://aabidlwc-developer-edition.ap16.force.com/services/apexrest/ringcentralwebhook"

}

}


Please help me, I'm trouble with this.

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.

1 Answer

Phong Vu avatar image
Phong Vu answered Aabid Khan edited

Where and how do you handle the validationToken?

Please read this dev guide to learn more how to useRingCentral WebHooks notification.

3 comments
1 |3000

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

Aabid Khan avatar image Aabid Khan commented ·

I' sending the following parameter in header & body, If I'm wrong please correct me: -

In header

Accept : application/json

Authorization : Bearer MyAccessToken

Content-Type : application/json

In Body

Json Data =>

{

"eventFilters": [

"/restapi/v1.0/account/~/extension/~/message-store?type=SMS&direction=Inbound"

],

"deliveryMode": {

"transportType": "WebHook",

"address": "https://aabidlwc-developer-edition.ap16.force.com/services/apexrest/test/v1"

}

}


but it give me 500 error, if I miss something or doing any mistake please correct me.

Thank you

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ Aabid Khan commented ·

That is the code you subscribe for webhooks notification. You still have to implement your code to handle the notifications where you must handle (return) the validation token. Read the dev guide carefully.

0 Likes 0 ·
Aabid Khan avatar image Aabid Khan Phong Vu ♦♦ commented ·

can we please specify the mistake in returning validation token in apex.

I'm new in this platform that's why I'm facing lots of problem.

to handle Webhook I'm creating rest resources but not able to found correct way.

@RestResource(urlMapping='/test/v1/*')

global class ringcentralWebhook

{

@HttpPost

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', description=s);

insert c;

String VToken = req.params.get('validation-token');

return VToken;

}

}

Thank you. @Phong Vu

0 Likes 0 ·

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