Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add current datetime in POST API request? [closed]

Tags:

postman

I want the start and end date to be in current datetime. I don't know whether it is possible. I need that because I want to trigger the data everyday using my pipeline.

Please see the image here

like image 859
Azim Kamal Avatar asked Jul 11 '26 02:07

Azim Kamal


1 Answers

You can create an environment variable in the pre-request-script of the request and then use that variable in the body

var now = new Date();
var timestamp = now.toISOString(); //or whatever format you want.
pm.environment.set("timestamp", timestamp);

alternatively, instead of pm.environment.set you can also use pm.variables.set (like shown in Danny Daintons answer) so the timestamp will only be available in the current request instead of the whole environment.

enter image description here

like image 80
derpirscher Avatar answered Jul 15 '26 16:07

derpirscher



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!