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?
Asked
Active
Viewed 1.7k times
3 Answers
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.

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.

vlad mcandrew
- 189
- 9
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

user1986514
- 1
- 3