Skip to main content
Solved

Cannot add a dictionary variable to a list (any)

  • Oct 15, 2026 3:29 PM UTC
  • 6 replies
  • 65 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

Best answer by Uzumaki

​@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.

View original
This topic has been closed for replies.

6 replies

Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+6
  • Automation Anywhere Team
  • Oct 15, 2026 5:14 PM UTC

​@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
  • Answer
  • Oct 15, 2026 5:24 PM UTC

​@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.


  • Cadet | Tier 2
  • Oct 18, 2026 12:49 PM UTC

Thanksfor your sharing 


  • Cadet | Tier 2
  • Oct 18, 2026 12:57 PM UTC

Thanks for sharing 😊but getting error when apending dict tolist did you solve it by using string conversation 


Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+6
  • Automation Anywhere Team
  • Oct 19, 2026 11:53 AM UTC

​@Uzumaki Could you not use a data table?


Uzumaki
Forum|alt.badge.img+2
  • Author
  • Navigator | Tier 3
  • Oct 19, 2026 1:03 PM UTC

​@Uzumaki Could you not use a data table?

Yes, a data table would’ve worked. I typically avoid them though because when updating a record value, you have to use the record: update column for every value. No way to update all values in a record in one go. Personal preference, but either way would work.