4

I am trying to make a POST request to create a new resource. In the request body it needs time stamp that is current timestamp, how to add the timestamp , how to parameterize it to current timestamp?

NRM
  • 271
  • 2
  • 3
  • 6

3 Answers3

7

If it's a just timestamp you need, just add {{$timestamp}} to the request body as the value.

This would give you a Unix timestamp but if you want to use a specific format - you can use moment to do this.

How do I format {{$timestamp}} as MM/DD/YYYY in Postman?

Danny Dainton
  • 23,069
  • 6
  • 67
  • 80
0

In jquery do this:

$.post(URL,data,function(result,err){
     //do whatever with data
}

In the data variable have data equal to what you need to send. To add the time stamp use

Let ts = new Date(Date.now())

And set data as ts.

0

{{$timestamp}} works only for Postman.

What should be the format to pass the timestamp directly to a variable of the JSON payload? I have been using Rest assured for api automation. Below is the JSON payload and i need to pass the Current time stamp to the clientTime field

{ "appVersions": { "APK": { "versionCode":4150, "versionName":"2.0.3" } }, "bEnableGlobalPayment":true, "clientTime":1551829145, }
osundblad
  • 2,675
  • 1
  • 29
  • 34