Invoking actions using the Common REST API


You can use the Common REST API doAction endpoint to invoke an action.

Before you begin

Invoking an action using the doAction endpoint

The doAction endpoint uses the POST method to invoke an action for a view. Use a URL based on the following structure:

https://<hostName>:<portNumber>/cra/serviceGateway/services/<serviceName>/doAction?parms=<parms>

The variables represent the following values:

  • <hostName> is the name of the mainframe host where the CRA server is running.
  • <portNumber> is the port number of the CRA server.
  • <serviceName> is the name of the service as it appears on the list. For more information, see To retrieve a list of services.

Authorization

Name

Located in

Description

Authorization

header

Authorization token formatted as 'Bearer [token]'

Query parameters

The doAction endpoint accepts the following case-sensitive parameters:

Parameter

Description

action

(required) Action name

To get a list of available actions and their parameters, use the getAcTbl endpoint. See Retrieving-view-actions-using-the-Common-REST-API.

Example: MLCMD

lineCmd

Indicates if the the action is a line command

Values: Y or N

rowNum

Row number in the view upon which to invoke the action

Obtain this value from the data endpoint in an open session or after a session has opened.

Required

formId

Form number to use when carrying out the action

For most requests, the value is 0.

parms

Action parameters

Use parms to provide the action with specific information for the action to work successfully. Only actions that are not line commands use values specified in the parms parameter.

Specification of one or more values using parms is optional and depends on what the action requires. See the view’s action documentation for a list of actions and what, if any, parms are needed for each of them.

Header parameter

Parameter

Description

session

Session token you obtained using the data endpoint. For more information, see Retrieving-view-data-using-the-Common-REST-API.

Response data

There are three different possible formats for the response data based on the nature of the action.

Simple Status

Some commands return a simple status indicating that the action was performed. The current data your application may have is now stale and should be refreshed.

The following example shows using the PURGE (P) action from AutoOPERATOR to purge the output of a held job.

To invoke the action, perform a POST as follows:

https://<hostname>:<portnumber>/cra/serviceGateway/services/Mva/doAction?action=P&lineCmd=Y&rownum=2&formId=0&parms=%27MVSABC1X%27%20%27J0538551%27

Note

All the parameters are on a single line in the URL with no spaces. The parameter syntax includes single quotes and spaces, which have been replaced with %27 and %20 respectively. This makes the string conform to the URL standards.

This invocation purges the job named MVSABC1X with the job ID J0538551.

As with all other POST operations, the user token is sent as the body content of the request.

The following shows a successful response:

{
"session":"8098ae2c-ab69-4ed1-95df-8c8507455afb",
"version":"1.0",
"status":"0,*,DOACTION,0"
}

Status with command

Some commands return a simple status along with a command to be executed. BMC AMI Ops Explorer uses this command to open a new view. Your application may decide to use the command to fetch more data for a related view.

The following example shows how to navigate to the Real-time TCP CPU utilization view.

To invoke the action, perform a POST as follows:

https://<hostname>:<portnumber>/cra/serviceGateway/services/Mva/doAction?action=T&lineCmd=Y&rownum=3&formId=0

Note

All the parameters are on a single line in the URL with no spaces. The parameter syntax includes single quotes and spaces, which have been replaced with %27 and %20 respectively. This makes the string conform to the URL standards.

The rownum parameter is an index into the view data from the JCPU view.

The following shows a successful response:

{
"session":"9bf94083-03e1-484c-b266-9853ce36adbd",
"version":"1.0",
"command":"VIEW JTCB *    81",
"status":"0,*,DOACTION,0"
}

The desired data for this action is contained in the JTCB view.

Dialog prompt

Complex commands return information that must be filled out and returned using the lcdReply endpoint. Dialog data is returned in HTML format. You can present the HTML to a user or handle it programmatically. In either case, the data for the fields described in the HTML must be returned in the lcdReply endpoint.

The following example shows cancelling a job from the JCPU view.

To invoke the action, perform a POST as follows:

https://<hostname>:<portnumber>/cra/serviceGateway/services/Mva/doAction?action=C&lineCmd=Y&rownum=3&formId=0

Note

All the parameters are on a single line in the URL with no spaces. The parameter syntax includes single quotes and spaces, which have been replaced with %27 and %20 respectively. This makes the string conform to the URL standards.

The following shows a successful response:

{

     "mvi-actions":"<mvi-actions><mvi-actions>\\n<mvi-action\\n discard=\"no\"\\n validate=\"yes\">\\n<mvi-command>END\\n</mvi-command>\\n<mvi-label>OK\\n</mvi-label>\\n<mvi-title>to terminate the address space\\n</mvi-title>\\n<mvi-primary-command>END\\n</mvi-primary-command>\\n<mvi-response-action>\\n</mvi-response-action>\\n</mvi-action>\\n<mvi-action\\n discard=\"no\"\\n validate=\"no\">\\n<mvi-command>CANCEL\\n</mvi-command>\\n<mvi-label>Cancel\\n</mvi-label>\\n<mvi-title>to abort address space termination\\n</mvi-title>\\n<mvi-primary-command\\n minimum=\"3\">CANcel\\n</mvi-primary-command>\\n<mvi-response-action>\\n</mvi-response-action>\\n</mvi-action>\\n<mvi-action\\n discard=\"no\"\\n validate=\"no\">\\n<mvi-command>HELP\\n</mvi-command>\\n<mvi-label>Help\\n</mvi-label>\\n<mvi-title>to view related help\\n</mvi-title>\\n<mvi-primary-command>HELP\\n</mvi-primary-command>\\n<mvi-response-action>\\n</mvi-response-action>\\n</mvi-action>\\n</mvi-actions>\\n","help":"<help><help>\\n<head>\\n<title>CANCEL Address Space Confirmation\\n</title>\\n</head>\\n<body>\\n<p>This panel confirms or aborts the MVS CANCEL of a specified address space. The CANCEL can optionally include the DUMP option.\\n</p>\\n<p>END (OK in MVE) continues the request to terminate the specified address space. To reduce the possiblitiy of accidentally terminating an address space, a confirmation field is displayed which must be set to Y.\\n</p>\\n<p>CANcel aborts the request to terminate the specified address space.\\n</p>\\n</body>\\n</help>\\n",
     "session":"8c5e075e-52af-4bec-84a4-4b14458af129",
     "html":"<html><html>\\n<head>\\n<title>CANCEL Address Space Confirmation\\n</title>\\n<meta\\n
name=\"MVEsize\"\\n content=\"400,250\">\\n</meta>\\n<meta\\n name=\"MVEposition\"\\n content=\"0,0\">\\n</meta>\\n</head>\\n<body>\\n<table\\n cellspacing=\"10%\"\\n border=\"0\">\\n<tr\\n align=\"left\">\\n<td\\n align=\"right\"\\n nowrap=\"nowrap\">Enter Y to confirm:\\n</td>\\n<td\\n align=\"left\"\\n nowrap=\"nowrap\">\\n<input\\n type=\"text\"\\n name=\"cancconf\"\\n value=\"\"\\n error=\"\"\\n size=\"2\"\\n maxlength=\"1\"\\n align=\"left\">\\n</input>\\n</td>\\n<td\\n align=\"right\"\\n nowrap=\"nowrap\">        Enter Y for a dump:\\n</td>\\n<td\\n align=\"left\"\\n nowrap=\"nowrap\">\\n<input\\n type=\"text\"\\n name=\"cancdump\"\\n value=\"\"\\n error=\"\"\\n size=\"2\"\\n maxlength=\"1\"\\n align=\"left\">\\n</input>\\n</td>\\n</tr>\\n<tr\\n align=\"left\">\\n<td\\n align=\"left\"\\n colspan=\"4\"\\n nowrap=\"nowrap\">\\n<b> \\n</b>\\n</td>\\n</tr>\\n<tr\\n align=\"left\">\\n<td\\n align=\"right\"\\n nowrap=\"nowrap\">Job Name:\\n</td>\\n<td\\n align=\"left\"\\n nowrap=\"nowrap\">\\n<b>MVSSOS1X\\n</b>\\n</td>\\n<td>\\n</td>\\n<td>\\n</td>\\n</tr>\\n<tr\\n align=\"left\">\\n<td\\n align=\"right\"\\n nowrap=\"nowrap\">Job Id:\\n</td>\\n<td\\n align=\"left\"\\n nowrap=\"nowrap\">\\n<b>J0539818\\n</b>\\n</td>\\n<td>\\n</td>\\n<td>\\n</td>\\n</tr>\\n<tr\\n align=\"left\">\\n<td\\n align=\"right\"\\n nowrap=\"nowrap\">Step Name:\\n</td>\\n<td\\n align=\"left\"\\n nowrap=\"nowrap\">\\n<b>MVSSOSTC\\n</b>\\n</td>\\n<td\\n colspan=\"2\"\\n align=\"left\"\\n nowrap=\"nowrap\">or STC Identifier\\n</td>\\n</tr>\\n<tr\\n align=\"left\">\\n<td\\n align=\"right\"\\n nowrap=\"nowrap\">ASID (Dec):\\n</td>\\n<td\\n align=\"left\"\\n nowrap=\"nowrap\">\\n<b>81\\n</b>\\n</td>\\n<td>\\n</td>\\n<td>\\n</td>\\n</tr>\\n<tr\\n align=\"left\">\\n<td\\n align=\"right\"\\n nowrap=\"nowrap\">ASID (Hex):\\n</td>\\n<td\\n align=\"left\"\\n nowrap=\"nowrap\">\\n<b>0051\\n</b>\\n</td>\\n<td>\\n</td>\\n<td>\\n</td>\\n</tr>\\n<tr\\n align=\"left\">\\n<td\\n align=\"right\"\\n nowrap=\"nowrap\">MVS System:\\n</td>\\n<td\\n align=\"left\"\\n nowrap=\"nowrap\">\\n<b>SJSC\\n</b>\\n</td>\\n<td>\\n</td>\\n<td>\\n</td>\\n</tr>\\n</table>\\n</body>\\n</html>\\n",
     "version":"1.0"
}

Note

Several of the JSON properties are long strings. The <html> property contains HTML that is suitable for prompting a user.

If you are running a dialog prompt action, to complete the action, you must POST an lcdReply command:

http://<hostname>:<portnumber/cra/serviceGateway/services/Mva/lcdreply?command=END&cancconf=Y&cancdump=N

Note

All the parameters are on a single line in the URL with no spaces. The parameter syntax includes single quotes and spaces, which have been replaced with %27 and %20 respectively. This makes the string conform to the URL standards.

In this example, we obtain the command from the mvi-actions property. We obtain the cancconf and cancdump parameters from the <input> elements within the HTML.

If successful, the response contains a simple status:

{
"session":null,
"version":"1.0",
"status":"0,*,DOACTION,0"
}

HTTP status and reason codes

The following HTTP status codes are returned for the indicated errors, and the response body is a standard error response body providing the reason code indicated and associated error message.


Error Code

Explanation

200

Successful completion

403

Unauthorized. The authorization token is missing, invalid or expired

404

The path is not valid. The message indicates what the issue is.

Message

Explanation

Invalid product name

You entered an empty product name.

Invalid view

You entered an empty BMC AMI Ops view name.

Invalid context

You entered an empty context name.

Invalid server

You entered an empty server name.

Invalid system

You entered an empty system name.


 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*