Passing sys_created_on date parameter in REST api

Raks
Tera Contributor

Hi All,

Need help. I am trying to build a dynamic query where sys_created_on is passed to the table using the sysparam=sys_created_on attribute. Now my question here is how to build this query.

Source= Json.Document(Web.Contents("https://servicecentral.capgemini.com/api/now/table/prolem",
[Query=sysparm_query=sys_created_on%3E%3Djavascript%3Ags.dateGenerate(dtquery)]))

where dtquery is the date variable holding the date value.

Just to add I am using this query to get data into power bi using power query.

Please guide

 

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Raks 

you should send it like this

Send the date as dynamic value which is highlighted in bold

sysparm_query=sys_created_onON2020-07-17@javascript:gs.dateGenerate('2020-07-17','start')@javascript:gs.dateGenerate('2020-07-17','end')

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

9 REPLIES 9

The query which you have provided works from postman and api explorer but not from tool I'm trying to integrate with..not sure what could be the cause.

possibly check the character encoding or any special character getting replaced etc

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Harsh Vardhan
Giga Patron

this should be something like below.

 

sysparm_query=sys_created_on<javascript:gs.dateGenerate('2020-08-01','00:00:00')

 

make the changes in < or < based on your need. 

Ankur Bawiskar
Tera Patron
Tera Patron

@Raks 

Hope you are doing good.

Let me know if that answered your question.

If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

shafeeqrafeek
Tera Contributor

how to set timezone? it automatically assumes that the date time given is in local timezone but we need to set it as UTC