vendredi 13 décembre 2019

How to set current date and time in a request in SoapUI ?

If you need to set the current date and time in a request while using SoapUI for testing a service (eg. a RESTful POST call), then you can click this link to get the basic info about how to do that very easily.

On the above link, the current date only is set, but here is the improvement needed to also have the current time in the request :

"${=def now = new Date();now.format("yyyy-MM-dd HH:mm:ss")}"

Here is a sample of a full resquest that includes the current date and time that is sent to the server in a RESTful POST request :

{
   "payments":[
   ],
   "date":"${=def now = new Date();now.format("yyyy-MM-dd HH:mm:ss")}",
   "depositPaymentMode":{
      "id":"2519386551735787230",
   },
   "bankAccountData":{
      "id":19,
   },
   "total":1954.08,
}