Upload multiple file in one key

Hello Guys, I have an issue

I want to implement from postman(form-data)

I have the syntax
${files}= Evaluate {‘item_images’: (os.path.basename(“${filePath1}”), open(“${filePath1}”, ‘r+b’), “image/png”),‘item_images’: (os.path.basename(“${filePath2}”), open(“${filePath2}”, ‘r+b’), “image/png”)}
only filePath2 was created

Hi Muhammad,

It’s not clear what you are trying to do here? You mentioned postman(form-data), then showed a screenshot of what I guess is the app your trying to test, then give some robot code that looks like you might be trying to create a python dictionary?

It’s a good idea to indicate what library you are using.

If I’m guessing correctly you want to construct the http post body and post form data with requests library? (i’ll base my answer on this guess)

So first problem I see and it probably goes to explain why

In a dictionary, the key can only exist once:

Here you repeated item_images

So perhaps this will give you what you want?:

${files}= Evaluate {‘item_images’: [(os.path.basename(“${filePath1}”), open(“${filePath1}”, ‘r+b’), “image/png”), (os.path.basename(“${filePath2}”), open(“${filePath2}”, ‘r+b’), “image/png”)]}

But that’s just a guess, normally people wouldn’t try to jam everything into 1 line with python code like this as it’s difficult for people who are not programmers to understand what’s happening.

The builtin keywords like Create List and Create Dictionary make it much clearer what you’re constructing, also OperatingSystem Library has keywords for files and Collections has keywords for manipulating lists and dictionaries if you need them.

Hopefully this helps,

Dave.