Skip to main content
Question

Cannot add a dictionary variable to a list (any)

  • October 15, 2026
  • 2 replies
  • 12 views

Uzumaki
Forum|alt.badge.img+2

Cannot add a dictionary (any) to a list variable (any). Getting an exception that says “Data type of to-be-added item is different from the data type of List”

 

Does anyone know of a workaround? Thank you

2 replies

Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+6
  • Automation Anywhere Team
  • October 15, 2026

​@Uzumaki Not enough information to understand why you are doing this. Also specify which actions you are using. 


Uzumaki
Forum|alt.badge.img+2
  • Author
  • Navigator | Tier 3
  • October 15, 2026

​@Uzumaki Not enough information to understand why you are doing this. Also specify which actions you are using. 

I’m looping through a Sharepoint directory and extracting metadata for all files found (size, lastModified, id, relPath, ect..). My plan is to loop through each file, assign a dictionary using dictionary: assign dicFileMetadata with that file’s contents, and add dicFileMetadata to a list lisFileData using list: add item. Working with the JSON package can be a pain and until they add a JSON variable, I’d rather convert a list of dictionaries into JSON using python.

I actually figured out the problem. lisFileData was being used upstream in this same task bot, resulting in an error when I tried to add a variable of a different data type to it. Whoops.