Example for Using Input Parameter

You can use the input parameter in the JavaScript format in the request body.

In this example, the endpoint is https://abc.example.com:8543/users/rest/asset/roles/user. This endpoint uses the POST method for a HTTP request and the following body content:

{
   "users": [
       {"id":"cn= user1,cn=system,cn=userapplication,cn=app1,ou=example,o=com"}
   ]
}

To change the body content to JavaScript and provide cn from defined input parameters, perform the following steps:

  1. In Step1: Provide input parameters, specify {P1} as input parameter with parameter value cn.

    Add the test values for {P1} as user and system.

  2. In step 2: Configure Request and Response, change the request body message as follows:

    function main({P1}) {
    var cnValues = "cn=" + {P1}[0] + ",cn=" + {P1}[1]+ ",cn=userapplication,cn=app1,ou=example,o=com";
    var json = {
                    "users": [
                      {"id":cnValues}
                    ]
                    };
    return json;
    }

You can provide multiple test values to a parameter {P1} and use the values as array in the JavaScript function for Resource/ API Path and Body.

NOTE:If {P1} has only one input value, Access Manager interprets {P1} in JavaScript as a string and not as an array. Hence, for a single input value use {P1} instead of using {P1}[0].

If multiple values are available for {P1}, JavaScript returns all elements that are separated by a comma (,). For example, test1,test2. Whereas, {P1} in plain text returns only the first value. For example, test1.