How to iterate same request in loop for different files uploads types

I have a scenario where api uploads a document, can simply create duplicate request but don’t want that like in the image image
@anon46315158 any leads pls
Want to execute the same request 4 times with different file types each.

How can execute it in Test suite with different file set


String ACCESS_TOKEN = WebUI.callTestCase(findTestCase('API_Testing/AccessTokenGeneration'), [:], FailureHandling.CONTINUE_ON_FAILURE)

def request = ((findTestObject('Object Repository/Upload Document')) as RequestObject)

'Create new ArrayList'
ArrayList<TestObjectProperty> HTTPHeader = new ArrayList<TestObjectProperty>()

HTTPHeader.add(new TestObjectProperty('Authorization', ConditionType.EQUALS, 'Bearer' + ACCESS_TOKEN))

request.setHttpHeaderProperties(HTTPHeader)

response = WS.sendRequest(findTestObject('Upload Document', [('RESOURCE_PREFIX') : GlobalVariable.RESOURCE_PREFIX
            , ('ACCESS_TOKEN') : GlobalVariable.ACCESS_TOKEN, ('ID') : GlobalVariable.ID]))

WS.verifyResponseStatusCode(response, 200)

you have to parametrize the value for the ‘file’ (as you did for id) and ofcourse create the variable in the tab (you can put your current value there for a quick test.

on the testcase, you create a list with the needed paths to the files (a list of strings defining the path to the files) and iterate over it, calling your request object and bind the value. easy peasy.

I wont do that. For katalon related stuff i am reachble only on the forum, i like to keep my email adress private.

However you are on the right path, keep exploring and tell us where you are blocked… But i will be glad if you can figure it out. Is not that hard, just tricky.
We are around to guide you.

1 Like

tried another time
failure is at

def list = ['C://Users/path/Uploadfiles/text.jpg' , 'C://Users/path/test.txt']
for (item in list) {
**response = WS.sendRequest(findTestObject('Object Repository/Upload Document-Docx'), item)**
}
groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords.sendRequest() is applicable for argument types: (com.kms.katalon.core.testobject.RequestObject, java.lang.String) values: [TestObject - 'Object Repository/Upload Document-Docx', ...]
Possible solutions: sendRequest(com.kms.katalon.core.testobject.RequestObject), sendRequest(com.kms.katalon.core.testobject.RequestObject, com.kms.katalon.core.model.FailureHandling)

What is item?

image

That is the error. It does not belong there.

1 Like

agree but how do loop the list ?

You have to get rid off the errors first.
And learn to not send/request emails

1 Like

Thanks!! and Apologies

1 Like

Apologies accepted.
I will take a closer look at your use case, as my free time will afford it… But you have to understand, all of us from this comunity have also jobs to do… families… dogs… And so on…

1 Like

Odd that it complains about ":" but talks about the wrong index…

Regardless… if you’re showing me the source there, you must escape backslashes (with another backslash, which, confusingly, is the escape character, too).

So, replace all \ with \\

C:\\Users\\...

By the way, do you have a user called path? Or is that a typo?

1 Like

Thanks @Russ_Thomas …jst updated the comment with some changes…not sure what’s wrong

path is replaced by username
but some thing is wrong :slight_smile:

I asked you before, what is item?

If you think you’re somehow parameterizing that call, you’re not - at least, I see no evidence of it.

I’m probably the worst person to help you with this - I call Web Services directly, in JavaScript, and read the returned values directly, too.

That said, make sure you read and understand this:

@anon46315158 explained quite clearly what you need to do, here.

I gave a you a link to the documentation that explains parameterization.

I said your code is not using parameters. That is what is wrong.

1 Like

I already told you, I don’t test WS like this. The only way I could do that for you, is to read the documentation for you, write the code for you, and paste it here for you.

Clear?

Yes agree, Thanks and Apologies :pray:

Thanks but this leads to me helping you out eventually and found a bug, :slight_smile:
now will try to work with multiple files iteration which i don’t know but will try . :crossed_fingers:

Thank you but again apologies :pray: