Question

How do I pass list, dictionary or datetime type variables as input to the Deploy Bot API?

  • 21 March 2022
  • 4 replies
  • 406 views

Hi,

 

I'm trying to deploy bots with input parameters using Automation Anywhere API. I've successfully managed to pass string, number and boolean variables to the bot, but I can't seem to figure out what is the correct json syntax to pass dictionaries, list or datetime variables. I've looked for it in the swagger (https://dev-damantia.my.automationanywhere.digital/swagger/) but can't find information about it

 

I'm using the Postman collection provided by @MICAH SMITH​  in this video https://youtu.be/UZJ68r64oxA

 

Here is what I'v tried so far:

-List:

{

  "fileId": *****, //id of the bot to execute

  "runAsUserIds": [

    *** //id(s) of the user account to run the bot - must have default device unless specified below

  ],

  "poolIds": [],

  "overrideDefaultDevice": false,

  "callbackInfo": {

    "url": "https://callbackserver.com/storeBotExecutionStatus", //Callback URL - not required, but can be used - can be removed if no callback needed

    "headers": {

      "X-Authorization": "{{token}}" //Callback API headers. Headers may contain authentication token, content type etc. Both key & value are of type string.

    }

  },

  "BotInput": { //optional values to map to the bot...NOTE: These values must match the exact variable names and must be defined as input values

    "lInput1": {

      "type": "LIST", //Type can be [ STRING, NUMBER, BOOLEAN, LIST, DICTIONARY, DATETIME ]

      "list": ["Value11","Value12"] //key must match type, in this case string

    },

    "lInput2": {

      "type": "LIST",

      "list": ["Value21","Value22"] //key must match type, in this case string

    }

  }

 

-Dictionary:

{

  "fileId": ******, //id of the bot to execute

  "runAsUserIds": [

    *** //id(s) of the user account to run the bot - must have default device unless specified below

  ],

  "poolIds": [],

  "overrideDefaultDevice": false,

  "callbackInfo": {

    "url": "https://callbackserver.com/storeBotExecutionStatus", //Callback URL - not required, but can be used - can be removed if no callback needed

    "headers": {

      "X-Authorization": "{{token}}" //Callback API headers. Headers may contain authentication token, content type etc. Both key & value are of type string.

    }

  },

  "BotInput": { //optional values to map to the bot...NOTE: These values must match the exact variable names and must be defined as input values

    "dInput1": {

      "type": "DICTIONARY", //Type can be [ STRING, NUMBER, BOOLEAN, LIST, DICTIONARY, DATETIME ]

      "dictionary": [{"Key1":"Value1"}] //key must match type, in this case string

    },

    "dInput2": {

      "type": "DICTIONARY",

      "dictionary": [{"Key2":"Value2"}] //key must match type, in this case string

    }

  }

}

 

-Datetime:

 

{

  "fileId": *******, //id of the bot to execute

  "runAsUserIds": [

    *** //id(s) of the user account to run the bot - must have default device unless specified below

  ],

  "poolIds": [],

  "overrideDefaultDevice": false,

  "callbackInfo": {

    "url": "https://callbackserver.com/storeBotExecutionStatus", //Callback URL - not required, but can be used - can be removed if no callback needed

    "headers": {

      "X-Authorization": "{{token}}" //Callback API headers. Headers may contain authentication token, content type etc. Both key & value are of type string.

    }

  },

  "BotInput": { //optional values to map to the bot...NOTE: These values must match the exact variable names and must be defined as input values

    "dtInput1": {

      "type": "DATETIME", //Type can be [ STRING, NUMBER, BOOLEAN, LIST, DICTIONARY, DATETIME ]

      "datetime": "03/02/1999" //key must match type, in this case string

    },

    "dtInput2": {

      "type": "DATETIME",

      "datetime": "03/05/1999" //key must match type, in this case string

    }

  }

}

 

With all these API requests the bot is being deployed, but it is receiving empty variables. What should be the correct json syntax for these data types?

 

Thank you


4 replies

Userlevel 3
Badge +6

@Eduardo Martínez Hernández​ Refer below sample:

"botInput": {

        "dict_input": {

            "type": "DICTIONARY",

            "dictionary": [

                {

                    "key": "key1",

                    "value": {

                        "type": "STRING",

                        "string": "value1"

                    }

                },

                {

                    "key": "key2",

                    "value": {

                        "type": "STRING",

                        "string": "value2"

                    }

                }

            ]

        },

        "list_input": {

            "type": "LIST",

            "list": [

                {

                    "type": "NUMBER",

                    "number": "123"

                },

                {

                    "type": "STRING",

                    "string": "liststring"

                }

            ]

        },

        "dt_input": {

            "type": "DATETIME",

            "string": "2022-03-22T00:15:00+05:30[Asia/Calcutta]"

        }

    }

Hello, @Sumit Kumar​ 

 

Thank you very much, I've tested it out and it works!

 

Cound you help with record/table format as well? I can't find the right way to set the schema

 

Thank you very much

Userlevel 6
Badge +9

Please find the sample at https://docs.automationanywhere.com/bundle/enterprise-v2019/page/enterprise-cloud/topics/control-room/control-room-api/deploy.html/p>

Badge

Hi,

I have been through your Query and to pass dictionaries, lists, and datetime variables as input parameters to Automation Anywhere bots using the Automation Anywhere API, you need to modify the JSON syntax in your API requests.

Follow these correct syntax for each data type-

  1. List
"BotInput": {
"lInput1": {
"type": "LIST",
"list": ["Value11", "Value12"]
},
"lInput2": {
"type": "LIST",
"list": ["Value21", "Value22"]
}
}
  1. Dictionary
"BotInput": {
"dInput1": {
"type": "DICTIONARY",
"dictionary": {
"Key1": "Value1"
}
},
"dInput2": {
"type": "DICTIONARY",
"dictionary": {
"Key2": "Value2"
}
}
}
  1. Datetime
"BotInput": {
"dtInput1": {
"type": "DATETIME",
"datetime": "1999-03-02T00:00:00Z"
},
"dtInput2": {
"type": "DATETIME",
"datetime": "1999-03-05T00:00:00Z"
}
}

Make sure to adjust the datetime format to match the expected format by the Automation Anywhere bot.

With these correct syntaxes, you will be able to pass dictionaries, lists, and datetime variables successfully to your bots via the Automation Anywhere API.

 

 

Reply