Knowledge Base

  1. Home
  2. Knowledge Base
  3. Technical Support
  4. Script Commands
  5. rtcActivateWebhook()

rtcActivateWebhook()

Invoke a REST/HTTP API to an external system.

This can be used to interact with other systems that are not accessible via browsers, such as a PSTN telephony infrastructure or an external Database.

Arguments:

NameTypeDescription
urlstring / object

External REST/HTTP server API URL.

It is also possible to use an object to set HTTP headers to the request (see additional details below).

input (optional)objectif not exist – send HTTP GET request.if exist – send HTTP POST with the input object converted to json as body of the request.
 answerstringThe external REST server response

Code example:

//This will send HTTP POST to the to save some data .rtcActivateWebhook(restURL, { value: sampleValue }, function(answer) { client.rtcInfo('rtcActivateWebhook Post answer ' + answer); }) //This will send HTTP Get to the same url to retrive the just posted data .rtcActivateWebhook(restURL, function(answer) { client.rtcInfo('rtcActivateWebhook Get answer' + answer); })

HTTP Headers

It is possible to set the Webhook HTTP header, by using the url argument as a json object and adding the header fields as the object’s internal json object. For example:

var webHookOptions = { url: 'https://[url]', headers: { 'X-HTTP-Method-Override': 'PATCH', 'Cache-Control': 'no-cache', 'Content-Type': 'text/xml' } }; client.rtcActivateWebhook(webHookOptions, {value: 100}, function(answer) { . . . })

A complete sample test script source, that uses the rtcActivateWebhook() command, can be found here.

Was this article helpful?

Related Articles

Leave a Reply 0 comments

Leave a Reply: