How to disconnect an agent via REST API

book

Article ID: 206678

calendar_today

Updated On:

Products

CA Automic Workload Automation - Automation Engine

Issue/Introduction

This article covers how to disconnect an agent via REST API that can then be called from a different script; for example, powershell

Requirements: "Disconnect Agent Connection" on every agent, but from a script

It's possible to retrieve the agents' information trough the rest API, but there is no POST method for http://aeserverr:8088/ae/api/v1/0/system/agents

Environment

Release : 12.3

Component : AUTOMATION ENGINE

Resolution

There is a script function that in general can be used to disconnect an agent. It would look like this:

:DISCONNECT 'HOST', 'AGENT_NAME'

where AGENT_NAME is replaced with the actual agent name that should be disconnected. More information can be found in the documentation here: https://docs.automic.com/documentation/webhelp/english/AA/12.3/DOCU/12.3/Automic%20Automation%20Guides/help.htm#Script/Reference/DISCONNECT.htm

The REST API can be used to then run the script using the POST scripts method (please note this cannot be run from client 0 since client 0 does not run executable objects), http://aeserverr:8088/ae/api/v1/[CLIENT]/scripts

where [CLIENT] is replaced by a working client number. The body/json in this case would look like this:

{
"script": ":DISCONNECT 'HOST', 'AGENT_NAME'"
}

More information on the scripts method can be found in the REST API documentation here: https://docs.automic.com/documentation/webhelp/english/AA/12.3/DOCU/12.3/REST%20API/Automation.Engine/index.html?overrideUrls=../Automation.Engine/swagger.json,../Continuous.Delivery.Automation/swagger.json,../Analytics/swagger.json,../Infrastructure.Manager/swagger.json#/scripts/activateScript