Home > Net >  How to set sysdate variable in the .json object?
How to set sysdate variable in the .json object?

Time:09-24

I have a post .json method where I send an object:

{
"targetSigningDate": "2021-09-22T21:00:00.000Z"
}

The "targetSigningDate" must always be 'sysdate'. Instead of manualy chaning the date, how to set sysdate into the object using pre-req. script ?

Thank you in advance

CodePudding user response:

JSON format does not expect a sysdate type value, so it won't be parsed as sysdate by parsers. You should do it programmatically yourself instead.

CodePudding user response:

I've figured it out by creating a pre-request script where I set a variable 'moment' and then set it to the environment

looks like this:

{
    var moment = require('moment')
    pm.environment.set("sysdate", moment())
}
  • Related