03 Nov 2020 12:15 PM
I am posting data points in pre-execution script and dont know how to create timestamp, trying Date.parse(api.date()) below, What's the correct way to do this ?
requestBody={
"type": "LB",
"series": [
{
"timeseriesId": "custom:alteon.CurrSessions",
"dimensions": {
"CUSTOM_DEVICE": "Load Balancers"
},
"dataPoints": [
[
Date.parse(api.date()),
api.randomNextInt()
]
]
}
]
};
request.setBody(requestBody);
Solved! Go to Solution.
03 Nov 2020 12:42 PM
I would use a variable and get the value before you start to create the requestBody. Something like this:
var timestampNow = api.date();
and then use the variable later. Or if you need it to be in a specific format you can use api.dateToFormat. You can find a couple of examples here