Use filters to list bots from a specific folder

This example shows how to send a POST request with filters to list specific bots. In this example, you have a folder that contains bots from several departments. Use the filters to return only the bots with finance in the name.

Prerequisites

JSON Web Token (JWT)
All Control Room APIs require a JSON Web Token (JWT) to access the APIs. Generate an authentication token using the Enterprise 11 Authentication API.
Permissions
You must have permission for the folder in which you want to perform operations. If you can view bots in the Control Room interface, then you can use this API.

See Enterprise 11: Bot permissions for a role.

Note:
  • Use the Swagger definition files installed with your Control Room to test the APIs. View the available Swagger APIs at http://<your_control_room_url>/swagger/.
  • You can also use a REST client to complete this task.

Procedure

  1. Add an authentication token to the request header.
    Note: Use the Enterprise 11 Authentication API to generate a JSON Web Token.
  2. Specify the method and URL.
    • Method: POST
    • URL: http://<your_control_room_url>/v1/repository/directories/14/files/list

      The example URL specifies a subfolder of the My Tasks folder.

  3. Add filter parameters in the request body.
    • Sort by name to return the results in alphabetical order.
    • Filter by the "finance" substring in the name field to return all bots containing finance in the name.
    Request body:
    {
      "sort":[{
        "field":"name",
        "direction":"asc"
      }],
      "filter":{
        "operator":"substring",
        "value":"finance",
        "field":"name"
        },
      "fields":[],
      "page":{ }
    }
  4. Send the request.
    • In a REST Client, click SEND.
    • In the Swagger interface, click Execute.

    Response body: The response for this example returns information on the three bots that contain the word finance in their names.

    {
      "page": {
        "offset": 0,
        "total": 6,
        "totalFilter": 3
      },
      "list": [
        {
          "id": "27",
          "parentId": "14",
          "name": "finance-new-vendor.atmx",
          "permission": {
            "delete": false,
            "download": true,
            "execute": false,
            "upload": true,
            "run": false
          },
          "lastModified": "2019-12-02T17:39:05.339Z",
          "lastModifiedBy": "19",
          "path": "Automation Anywhere\\My Tasks\\Q2\\finance-new-vendor.atmx",
          "directory": false,
          "size": "4602",
          "locked": false,
          "fileLastModified": "2019-12-02T17:38:56Z",
          "isProtected": false
        },
        {
          "id": "31",
          "parentId": "14",
          "name": "financeGenerateInvoice.atmx",
          "permission": {
            "delete": false,
            "download": true,
            "execute": false,
            "upload": true,
            "run": false
          },
          "lastModified": "2019-12-02T17:39:05.339Z",
          "lastModifiedBy": "19",
          "path": "Automation Anywhere\\My Tasks\\Q2\\financeGenerateInvoice.atmx",
          "directory": false,
          "size": "5060",
          "locked": false,
          "fileLastModified": "2019-12-02T17:38:56Z",
          "isProtected": false
        },
        {
          "id": "22",
          "parentId": "14",
          "name": "onboardingFinanceOrg.atmx",
          "permission": {
            "delete": false,
            "download": true,
            "execute": false,
            "upload": true,
            "run": false
          },
          "lastModified": "2019-12-02T17:39:05.339Z",
          "lastModifiedBy": "19",
          "path": "Automation Anywhere\\My Tasks\\Q2\\onboardingFinanceOrg.atmx",
          "directory": false,
          "size": "3910",
          "locked": false,
          "fileLastModified": "2019-12-02T17:38:56Z",
          "isProtected": false
        }
      ]
    }
Note: You can also run REST requests from a command terminal. The following is a curl request example. This example is formatted for readability. Replace the text inside the angle brackets, <authentication_token>, with your authentication token.
curl -X POST "<your_control_room_url>/v1/repository/directories/14/files/list"
     -H "accept: application/json" -H "X-Authorization: <authentication_token>"
     -H "Content-Type: application/json" -d "{
     \"fields\": [ ],
     \"filter\": {
    	\"operator\": \"substring\",
    	\"field\": \"name\",
    	\"value\": \"finance\" 
	}, 
    \"sort\": [ { 
    	\"field\": \"name\", 
    	\"direction\": \"asc\" 
    } ] 
}"