I want a rest api query to fetch first 5(recent) incidents from service now

vaidehi1
Mega Contributor

I want a rest api query to fetch first 5(recent) incidents from service now

5 REPLIES 5

HarshTimes
Tera Guru

Hi Vaidehi


add ORDERBYDESCsys_created_on in sysparm_query.generate the code and in the generated code change the limit to 5.



//Below code is servicenow generated code from rest API



var request = new sn_ws.RESTMessageV2();


request.setEndpoint('https://dev15501.service-now.com/api/now/table/incident?sysparm_query=ORDERBYDESCsys_created_on&sysp...


request.setHttpMethod('GET');



//Eg. UserName="admin", Password="admin" for this code sample.


var user = 'admin';


var password = 'admin';



request.setBasicAuth(user,password);


request.setRequestHeader("Accept","application/json");



var response = request.execute();


gs.log(response.getBody());


This is a correct answer I think someone should Mark it 🙂

tamilselvan
Kilo Explorer

@haresh its very use full for me but i want approved incident number fetch can pls help me

What do you mean by approved incident number? Generally there is no approvals in incidnet process. PLease send details about "approved incidents".

 

-Harsh