Skip to main content

OK I have another REST collector question. My collect section I am using POST with body. The body is JSON and it has to provide the time there (start and end). I was trying `${earliest}` and `${latest}` but it does not seem to work. I think it is expecting the date to be in a certain format. This collector is currently a bash script but I was thinking it would work as a REST collector. The bash script sets and start and end variable like this:start="$(date --date=-1days '+%F %H:%M:%S')"end="$(date --date=last-minute '+%F %H:%M:%S')"How can I do this with the REST collector? Ideas?

<@U01C35EMQ01&gt; you know of anyone that can help me?


Or use a fallback like this:


Remember that you must set earliest and latest fields in the job config for those variables to be defined


```Earliest: `${C.Time.strftime(new Date((earliest * 1000 || Date.now() - (246060*1000))), "%Y-%m-%d %H:%M:%S")}`Latest: `${C.Time.strftime(new Date((latest * 1000 || Date.now() - (60 * 1000))), "%Y-%m-%d %H:%M:%S")}````


If my collect method is POST with body, I do not have any collect parameters. Lets say this is the POST body:{"list": "value", "start": "this need to be earliest", "end": "this needs to be latest" }


How can I use what you provided in the POST body?


````{"list": "value", "start": "${C.Time.strftime(new Date((earliest * 1000 || Date.now() - (246060*1000))), "%Y-%m-%d %H:%M:%S")}", "end": "${C.Time.strftime(new Date((latest * 1000 || Date.now() - (60 * 1000))), "%Y-%m-%d %H:%M:%S")}" }````


thanks! I will give it a whirl


good stuff, it worked. that stuff with time and date javascript is the stuff I need to learn more about


Reply