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.

REST API - Date ("resolved_at" field) search

Ema5
Giga Contributor

Hello,

I'm trying to perform a search on Incident on a "resolved_at" field via REST API.

I understand how to query for specific parameters, such as:

/api/now/v1/table/incident?sysparm_query=resolved_at=ONLast15minutes

Unfortunately this code not works.

Does anyone have an idea on how to query for "resolved_at" field (with "ON Last 15 minutes" condition) on records via the REST API?

Thanks

1 ACCEPTED SOLUTION

snehabinani26
Tera Guru

Hi Ema,



Your query should be



'/api/now/v1/table/incident?sysparm_query=resolved_atONLast 15 minutes@javascript:gs.minutesAgoStart(15)@javascript:gs.minutesAgoEnd(0).



Hope this helps you


View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Ema,



Following query I obtained when I applied the filter condition you can try using the same and let me know



var query = 'resolved_atONLast 15 minutes@javascript:gs.minutesAgoStart(15)@javascript:gs.minutesAgoEnd(0)';



'/api/now/v1/table/incident?sysparm_query='+query



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

snehabinani26
Tera Guru

Hi Ema,



Your query should be



'/api/now/v1/table/incident?sysparm_query=resolved_atONLast 15 minutes@javascript:gs.minutesAgoStart(15)@javascript:gs.minutesAgoEnd(0).



Hope this helps you


Alikutty A
Tera Sage

Hi Ema,



Try this query in REST API Explorer resolved_atRELATIVEGE@minute@ago@15



Also make sure you have valid incident records with the resolved date


find_real_file.png



Thank You


Please Hit Like, Helpful or Correct depending on the impact of response


Ema5
Giga Contributor

Thanks a lot to all!!



The working query is the following:



https://<myinstance>/api/now/table/incident?sysparm_query=resolved_atONLast%2015%20minutes%40javascript%3Ags.minutesAgoStart(15)%40javascript%3Ags.minutesAgoEnd(0)



Regards