Support & information center

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 exists – send as HTTP POST with the input object converted to JSON as body of the request
If does not exist – send as HTTP GET 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);
    })Code language: JavaScript (javascript)

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) {
        . . .
    })Code language: JavaScript (javascript)

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

Was this article helpful?

Related Articles