Functions

Net.httpRequest(url, callback, options)

void

Performs a regular HTTP request. GET is the default request method. See VoxEngine Reference for the limits. TCP connect timeout is 90 seconds.

Example

The request with output of all possible Net.HttpRequestResult properties.

 Net.httpRequest("https://voximplant.com/", function(e) {
      if(e.code == 200) { 
        Logger.write("Connected successfully");
        Logger.write("code:  " + e.code);
        Logger.write("data:  " + e.data);
        Logger.write("error:  " + e.error);
        Logger.write("headers:  " + JSON.stringify(e.headers));
        Logger.write("raw_headers:  " + e.raw_headers);
        Logger.write("text:  " + e.text);
      } else { 
        Logger.write("Unable to connect");
      }
    },  { rawOutput: true } );
Parameters
  • url: String

    HTTP url to query

  • callback: Function (optional)

    Function to be called on completion. The function receives a response object of type Net.HttpRequestResult as a first argument

  • options: Net.HttpRequestOptions (optional)

    Advanced settings

Net.httpRequestAsync(url, options)

Promise

Performs an asynchronous HTTP request, i.e. the method returns a Promise which resolves with a Net.HttpRequestResult object. GET is the default request method. See VoxEngine Reference for the limits. TCP connect timeout is 90 seconds.

Example

Minimal example:

 Net.httpRequestAsync('https://voximplant.com/').then(function() { Logger.write("request complete"); });
Parameters
Returns
  • Promise

Net.sendMail(mailServerAddress, from, to, title, body, callback, options)

void

Send e-mail using specified e-mail server.

Example

Usage example

 Net.sendMail("smtp.server.com",
                 "from@server.com",
                 "to@server.com",
                 "Title of the letter",
                 "Body of the letter",
                 function stub(){},
                 {login: "login_from@server.com", password:"password_from@server.com"});
Parameters
  • mailServerAddress: String

    Address of mail server to use

  • from: String

    From address of e-mail message

  • to: String|Array

    To address or list of those

  • title: String

    Message title

  • body: String

    Message body

  • callback: Function

    Function to be called on completion

  • options: Net.SendMailOptions

    Advanced settings

Net.sendMailAsync(mailServerAddress, from, to, title, body, options)

Promise

Send e-mail using specified e-mail server

Example

See how to fill in the parameters

 Net.sendMail("smtp.server.com",
                 "from@server.com",
                 "to@server.com",
                 "Title of the letter",
                 "Body of the letter",
                 {login: "login_from@server.com", password:"password_from@server.com"});
Parameters
  • mailServerAddress: String

    Address of mail server to use

  • from: String

    From address of e-mail message

  • to: String|Array

    To address or list of those

  • title: String

    Message title

  • body: String

    Message body

  • options: Net.SendMailOptions

    Advanced settings

Returns
  • Promise