Giving me error as: {"code":"invalidDateFormat","message":"Invalid date format. Valid date format is

deepikamara
Tera Contributor

Hi,

 

In pre processing script : I am taking current and past 3 days date and passing it in response body as shown in the SS

-------------------------------------------------

(function execute(inputs, outputs) {
var now = new GlideDateTime();
    var threeDaysAgo = new GlideDateTime();
    threeDaysAgo.addDaysUTC(-3);  // Subtract 3 days
    outputs.updatedDateTo = now.getValue().replace(' ', 'T') + 'Z';
    outputs.updatedDateFrom = threeDaysAgo.getValue().replace(' ', 'T') + 'Z';
    gs.info("testing dates::"+typeof(outputs.updatedDateTo)+"::"+typeof(outputs.updatedDateFrom));
})(inputs, outputs);
 Giving me ouput: 2024-11-25T12:11:11Z
 
In Rest step:
---------------------------------------
deepikamara_0-1739276915191.png

 

Giving me error as: {"code":"invalidDateFormat","message":"Invalid date format. Valid date format is YYYY-MM-DDThh:mm:ssZ."}

 

But if i give custom date it is working fine

deepikamara_1-1739277139203.png

Can you please help me here.

12 REPLIES 12

deepikamara_0-1739339228297.png

 

@deepikamara 

this error is thrown by the REST Step?

If yes then it clearly says the date/time format is not correct.

Did you check the REST Step passed the correct date/time in that expected format?

 {"code":"invalidDateFormat","message":"Invalid date format. Valid date format is YYYY-MM-DDThh:mm:ssZ."}

If my response helped please mark it correct and close the thread so that it benefits future readers.

@deepikamara 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.