Pass parameters to the API calls

There are two different types of API call parameters, and cui.js handles each in a slightly different fashion.

1. Query String Parameters

Query String parameters are name/value pairs that cui.js will attach to the header of the API call. Here is a basic example of passing an id query string parameter to the getOrganizations() call. Note, cui.js looks for query string parameters inside its options object’s qs property.

 myCuiJs.getOrganizations({
    qs: [['id', 'YOUR-ORG-ID']]
 }).then(function(response) {
    // ...do something with response
    var organizationData = response;
 }).fail(function(err) {
    // ...handle error
    var errStr = myCuiJs.parseError(err);
 });

The cui.js qs property value is an array of arrays. The inner arrays are name/value pairs, and when multiple query string parameters are passed, each parameter must be wrapped inside its own array.

The RAML description of each API call dictates which query string parameters are allowed and/or required.

💡 Simplicity

All cui.js methods that wrap the APIs take a single options object parameter.
The properties of this options object use the same names as the underlying API-specific parameters.

2. URI Parameters

URI parameters are context-specific identifiers that cui.js uses when constructing the URL of the API call. Here is an example of a getOrganization() call that requires an organizationId parameter.

 myCuiJs.getOrganization({
    organizationId: 'YOUR-ORG-ID',
 }).then(function(response) {
    // ...do something with the response
    var organizationData = response;
 }).fail(function(err) {
    // ...handle error
    var errStr = myCuiJs.parseError(err);
 });

A comprehensive list of cui.js calls and their required URI parameters is available for Idm, Iot, and Admin.