To handle validation token, I'm creating below code.
@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 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": [
"/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/"
},
"expiresIn":100
}
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.