Toggle menu

apiclient

This module is used to send a request to any worker on an API Server.

Although not deprecated, this module has been superseded.
In end points, you should use:
- this.callWorkerMethod() to call other workers
- this.invokeEP() to call other end points
Both are part of the End Point this Object.
In forms, use .utilServerAPIServerCall.

Executed

Server-side.

Details

const apiclient = require('apiclient');

Once loaded the apiclient module is used to create a new API Server Client:

let client = new apiclient.ApiClient(options);

Where options is an object with the following optional properties:

NameDescription
userUsername for authentication*
passwordPassword for authentication*
apiKeyAPIKey for access*
idPrefix on the JSONRPC2 request ID
serverThe base address of the API Server. This value only needs to be provided if calling services on a remote API Server
serveridUsed when calling a worker assigned to the internal key
* see API Server Security for more information

Methods

Once loaded the following methods can be called from the client.

Invoke

Invokes the iCM Java API, used to call worker services on the API Server.

let request = client.invoke('service', 'method', parameters);

  • service - the name of the service (usually the name of a worker). This can include a full URL, like "http://myserver:5706/ajaxlibrary"
  • method - the method to be called on that service
  • parameters - an array or object of parameters passed to the method

Example

A request invoking the icmapi worker would be constructed as follows. In this example we are calling a worker secured by a username and password

function(params, credentials) {
    const apiclient = require('apiclient');
    let client = new apiclient.ApiClient({
        user:'MyUser',
        password:'MyPassword'
    });    
    let request = client.invoke('icmapi', 'CSArticle_get', {
        'get':'ArticleHeading',
        'set':{
            "ArticleID":304,
        },
    });
    return request;
}

Last modified on 27 May 2026