Passing List as Input Parameter for Python

Another question! I have a Python script that takes two parameters, a string and a list of strings containing two names.

def send_message(text,names = []):

in order to send a message to two people. I’m automating this using UiPath and have a list containing the two names that I want to send the ‘text’ to, but I am getting an error saying

Error invoking Python method —> RemoteException wrapping System.ServiceModel.CommunicationException: There was an error while trying to serialize parameter http://UiPath.Python.Host:args. The InnerException message was 'Type ‘System.Collections.Generic.List`1[[System.String, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089]]’ with data contract name ‘ArrayOfstring:’ is not expected.

when I try to pass the list I’ve created as an input parameter. Am I doing something wrong when I pass the list into Python? Thanks!

I’m able to pass the parameters perfectly @sunya

Can you post screenshot of how you are passing the parameters to the code and the code you have?

1 Like

Yes: here is how I’m passing in the input parameters:
Here is the ‘name_list’ that is being passed in:

And here is a sample of the Python I am using:

def send_text(text,rooms = []):
wb.send_user_message(text= text, file_list=file_list, markdown=markdown)
for name in rooms:
wb.send_message(text= text, file_list=file_list, markdown=markdown, name=name)

It should be passing in the two names as the ‘name_list’, then sending messages to the people inside of that list.

I just realized I’m trying to pass a String in, but it’s an array. Fixed it!

how to pass list obj?

Type argument must be string List?

Get Python Object is which the value you are trying to return in python code @KarthikBallary

So, whatever the type you are returning in python, change it to that type and get the object

if I do so I am getting python object error

Can you post what you are trying to return from python and what is the type of type argument in studio :slight_smile: (15.5 KB)
Pls help asap


pythonD1 pythonD2 PythonD3

The file is not even running for me @KarthikBallary

As it is working for you, try this
loop through the list in the python code itself and then add each value in the list to a string and return that string :slight_smile:

As I understand, you are trying to remove the duplicates in the code, that you can do using the existing activities by adding all the values to a array string type

I forgot to add arguments in python method. add it and run.
I need to pass list for other purpose. each value not a good idea. if it is possible to pass list

@HareeshMR: Pls send any sample file if you have

@sunya: What is the solution?