Get Exit Code of Action from API

Does anyone know how I can get the exit code of an action using REST API?

action/id/status only returns the following, for each computer:
Status
State isError
ApplyCount
RetryCount
LineNumber

We want to get the exit code of the action back, so we can send different messages based on it.

Hmm - nothing showing up in session relevance that gives a code. The different status are available though, would those work ?

Q: properties of type "bes action result"
A: computer of <bes action result>: bes computer
A: action of <bes action result>: bes action
A: apply count of <bes action result>: integer
A: retry count of <bes action result>: integer
A: line number of <bes action result>: integer
A: status of <bes action result>: bes action status
A: detailed status of <bes action result>: string

How does the console get this info if not from session relevance? Must be in the DB somewhere.

@gearoid Those are basically the same properties the api returns. I’m really needing the exit code though. I guess I could do something with line number. I could have the fixlet exit at a certain line depending on the exit code. I really don’t like that solution though, since the line number could change if I ever needed to add additional lines to the fixlet.

To James’ point. I see exit code in the ACTIONRESULTS table. I don’t really want to write a DB query against that table either, because we’ve been told those table structures could change with future upgrades. I did not find exit codes in the BES_ACTIONS, or BES_ACTION_DEFS views.

1 Like

It definitely feels like exit codes should be added to the session relevance properties for action results.

2 Likes

Sorry to bring this back from the dead, but I finally open a RFE for this.

This is a real limitation for us. When deploying actions via a workflow, utilizing REST API, we’re unable to get any detailed information back on action failures. If it were possible to get the exit code of an action via API we could add logic based on the reason for failure.

Link to RFE:

http://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=87203

There was some Action Exit Code logic added in 9.2.5 for at least the Console and WebReports so some of this might already have been addressed.

not sure if anyone saw this, but in 9.2.5.130 REST API, the exit code is reuturned, along with other useful info like start/end time and failed line number:

https://server:52311/api/action/{id}/status

<?xml version="1.0" encoding="UTF-8"?>
<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
	<ActionResults Resource="https://server:52311/api/action/{id}/status">
		<ActionID>{id}</ActionID>
		<Status>Open</Status>
		<DateIssued>Thu, 19 May 2016 19:40:12 +0000</DateIssued>
		<Computer ID="11656281" Name="server123">
			<Status>The action failed.</Status>
			<State IsError="0">4</State>
			<ExitCode>-2147024885</ExitCode>
			<ApplyCount>1</ApplyCount>
			<RetryCount>1</RetryCount>
			<LineNumber>23</LineNumber>
			<StartTime>Thu, 19 May 2016 19:44:07 +0000</StartTime>
			<EndTime>Thu, 19 May 2016 19:44:35 +0000</EndTime>
		</Computer>
	</ActionResults>
</BESAPI>
5 Likes

Yup, it is there. I must have missed that in the release notes.

I’m happy now :smile: