Generating current epoch timestamp in milliseconds

Our API expects device timestamp to be provided in every request header.
It needs to be valid epoch timestamp in milliseconds, not so much off from server time.
I’m struggling to find a way to achieve it in Katalon as requests in Object Repository don’t have script console (other than ‘Verification’ tab).

The closest I could get is to reference given header to local variable which in turn is referenced to global variable which is defined as ‘Value Type’: Range, and ‘Value’ (From/To) as ‘Value Type’: Method Call and ‘Value’ as: ‘Object Type’: Class, ‘Object’: java.lang.System and finally ‘Method’: currentTimeMillis()

But this gives me a range (as expected) of same timestamp, say: 1547827294485…1547827294485
(but at least I see actual time generated).

Pitty Class/Method cannot be referenced directly within Profile/Global Variable section…

Any help much appreciated.

Hi Kamil,

you can define your API test object and add headers later in the test (with current timestamp)

RequestObject ro = findTestObject("Misc/WStest")
ro.setHttpHeaderProperties(Arrays.asList
	(new TestObjectProperty("MyHeader", 
							ConditionType.EQUALS, 
							System.currentTimeMillis().toString())))
1 Like

Thank you, Marek. This resolved my problem. Really appreciate your help.