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:
State isError

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.


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:

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 REST API, the exit code is reuturned, along with other useful info like start/end time and failed line number:


<?xml version="1.0" encoding="UTF-8"?>
<BESAPI xmlns:xsi="" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
	<ActionResults Resource="https://server:52311/api/action/{id}/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>
			<StartTime>Thu, 19 May 2016 19:44:07 +0000</StartTime>
			<EndTime>Thu, 19 May 2016 19:44:35 +0000</EndTime>

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

I’m happy now :smile: