Can I get API url from data files (Data driven approach)

Hi,

We have like thousand of json files with one end point but multiple (thousand of json files).
e.g.

Is it possible to get the json file from data files (Test Data)?
sample
image

if not, what is the work around for this?

so that i can request http://endpoint/all/TEST_I.json

What do you mean by ā€œget the json fileā€? Get its name? Get its content?

get its name so that i can put it in the api url. :slight_smile:

Hi @angelo.dabu

My post can help: How to use Global Variable directly in Object Repository URL

  1. Add Global Variable in Profile (ā€œG_fileNameā€).
  2. Add Local Variable (ā€œfileā€ - to match yours URL) in request definition (Object Repository) and set type ā€œGlobal Variableā€. Select Global Variable, created in 1. in Default Value. This will link Local with Global.
  3. Loop in TC.

Code not tested, it is just idea:

import com.kms.katalon.core.testdata.TestDataFactory
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS

myData = TestDataFactory.findTestData('listOfFiles')
myData.allData.forEach()
{
	GlobalVariable.G_fileName = it[1] //Yes you will get array
	res = WS.sendRequest(findTestObject('fileRequestName'))
	//Do what you need with res
}
1 Like