Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

passing date values to rest api from scheduled job

samadam
Kilo Sage

I am trying to pass date values using setStringParameterNoEscape() but doesnt see to be taking the dates.

setStringParameterNoEscape('fromDate', yesterday);

I have the right dates when I print to logs. Is there something specific that needs to be done for date values.

6 REPLIES 6

samadam
Kilo Sage

Yes

Hello

 

Can you try this code see if this works - 

 

var today = new GlideDateTime();
today.addDaysUTC(-1);
var yesterday = today.getDate();

var r = new sn_ws.RESTMessageV2('TEST', 'GET');
r.setStringParameterNoEscape('fromDate', yesterday + ' 00:00:00');
r.setStringParameterNoEscape('toDate', yesterday + ' 23:59:59');
r.setEccParameter('skip_sensor', true);
var response = r.execute();

 

Regards,

Omkar