Retrieving list of available adhoc commands
Prev | Chapter 2. REST API | Next

## Retrieving list of available adhoc commands

### Using XML format

To retrieve a list of available adhoc commands, make a request using GET method for `/rest/adhoc/sess-man@domain.com` where `sess-man@domain.com` is jid of component you wish to see commands for. For example, entering the following url: http://localhost:8080/rest/adhoc/sess-man@domain.com in your browser will retrieve a list of all ad-hoc commands available at sess-man@domain.com. This action is protected by authentication done using `HTTP Basic Authentication`. Valid credentials will be those of users available in user database of this Tigase XMPP Server installation (username in barejid form).

Below is example result of that request:

    <items>
      <item>
        <jid>sess-man@domain.com</jid>
        <node>http://jabber.org/protocol/admin#get-active-users</node>
        <name>Get list of active users</name>
      </item>
      <item>
        <jid>sess-man@domain.com</jid>
        <node>del-script</node>
        <name>Remove command script</name>
      </item>
      <item>
        <jid>sess-man@domain.com</jid>
        <node>add-script</node>
        <name>New command script</name>
      </item>
    </items>

### Using JSON format

To retrieve a list of available adhoc commands in JSON, we need to pass `Content-Type: application/json` to HTTP header of request or add `type` parameter set to `application/json`. Example result below:

    {
        "items": [
            {
                "jid": "sess-man@domain.com",
                "node": "http://jabber.org/protocol/admin#get-active-users",
                "name": "Get list of active users"
            },
            {
                "jid": "sess-man@domain.com",
                "node": "del-script",
                "name": "Remove command script"
            },
            {
                "jid": "sess-man@domain.com",
                "node": "add-script",
                "name": "New command script"
            }
        ]
    }

Prev | Up | Next
Retrieving user avatar | Home | Executing example ad-hoc commands