How do I retrieve incident records for a specific date or date range using REST?

raovijay
Kilo Explorer

Hi,

I have a web application in which, I will have to list incidents for a chosen date or date range. I have this REST below url to which I want to pass date(s) as parameter.

https://instance.service-now.com/api/now/v1/table/incident?sysparm_display_value=true&active=true

Appreciate any help on this questions.

Thanks,

Vijay

1 ACCEPTED SOLUTION

Jamsta1912
Tera Guru

Hi Vijay,


Go to a list view of incidents in your instance, add conditions similar to those you would like in your query, right click the filter breadcrumbs and copy the url to get an idea of what the string should look like:


find_real_file.png


View solution in original post

3 REPLIES 3

Jamsta1912
Tera Guru

Hi Vijay,


Go to a list view of incidents in your instance, add conditions similar to those you would like in your query, right click the filter breadcrumbs and copy the url to get an idea of what the string should look like:


find_real_file.png


syedfarhan
Kilo Sage

Hi You can use this format


I would go with http://example.com/users/12345/bids?start=01-01-2012&end=01-31-2012.




https://instance.service-now.com/api/now/v1/table/incident?start=01-01-2012&end=01-31-2012


  • There shouldn't be a slash before the query string.
  • Avoid using slashes in the query string. It'll be easier that way.


Thanks


Thank you, Jamie and Farhan for giving your time answering my query.



I have another question, related to aggregate REST api. I am trying to retrieve incidents grouped by - sys_created_on and severity with below URL



https://instance.service-now.com/api/now/stats/incident?sysparm_count=true&sysparm_display_value=tru...


0:   {   "stats": { "count": "1"}


                                  "groupby_fields": [2]


                  0:   {


                                      "value": "3 - Low"


                            "field": "severity"}


                  1:   {


                            "value": "2009-04-30 00:34:45"


                            "field": "sys_created_on"


                                      }


                  }


        1:   {   "stats": {"count": "1"}


            "groupby_fields": [2]


        0: {



                  "value": "3 - Low"


                  "field": "severity" }


                  1:   {



                  "value": "2009-09-09 19:25:40"


                  "field": "sys_created_on"


                            }


}


I am getting above output, however - I want to truncate the time part during aggregation, such that it groups for the date only (and not including the time). Appreciate your help on this.



Regards,


Vijay