Adding DatePicker/TimePicker in API request

Hi i was earlier using postman . Now i have to switch to Katalon -

While implementing something that was on postman -
My req payload file is below-
{
“name”: “EventName{{timestamp}}”,
“description”: “EventDescription{{timestamp}}”,
“code”: “EventCode{{timestamp}}”
}

where time stamp set up was done in pre-requisite step in postman like tis -
postman.setGlobalVariable(‘timestamp’, (new Date()).toISOString().replace(/-|.|:|T/g,“”));

Can you tell me how i can set this in katalon web request

1 Like

Maybe like (I don’t know what you were trying to “replace()” though). You can change the format to how you want the date to look like.

timestamp = new Date().format("M/d/yyyy")

or

DateTimeFormatter screenFormat = DateTimeFormatter.ofPattern("MM/dd/yyyy")
DateTimeFormatter standardFormat = DateTimeFormatter.ofPattern("M/d/yyyy")

LocalDate localDate = LocalDate.now()

timestamp = localDate.format(standardFormat)
GlobalVariable.gScreenFormattedDate = localDate.format(screenFormat)

Sorry if my question sounds lame but can you tell me where i can use this snippet ?
should it be placed in a test case ?

I want my request body to replace the ${timestamp} automatically in katalon
earlier while using postman we had some pre-requisite step tab where we can write scripts to run before any web request

if i have to achieve same thing to replace timestamp in http body in katalon in web req how can i do that

1 Like

If you select the “Script” tab on your Test Suite (at the very bottom), you will see several pre and post methods that you can use for setting up and tearing down. Use a GlobalVariable here and it will be available through-out your whole Test Suite.