API to create incident ticket using servcienow api

Phanikanth
Kilo Contributor

HI,

I want to create incident ticket through servcienow API. Please suggest the POST api and request body. 

2 REPLIES 2

Community Alums
Not applicable

Hi, 

You can use the Table API for this purpose. 

The documentation and an example payload and response can be found at the developer site, here: https://developer.servicenow.com/dev.do#!/reference/api/sandiego/rest/c_TableAPI#table-POST

Your exact payload will differ, as it will depend on your mandatory fields etc in your instance. 

To insert into the incident table, you'd use the same URL as in the example on the above link, which is https://instance.service-now.com/api/now/table/incident

Mike

MattiasJonsson
ServiceNow Employee
ServiceNow Employee

Just have a look at the REST API Explorer, it will help you build the request and sample payload as well as provide you with script examples.

 

var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://INSTANCENAME.service-now.com/api/now/table/incident');
request.setHttpMethod('POST');

//Eg. UserName="admin", Password="admin" for this code sample.
var user = 'admin';
var password = 'admin';

request.setBasicAuth(user,password);
request.setRequestHeader("Accept","application/json");
request.setRequestHeader('Content-Type','application/json');request.setRequestBody("{\"short_description\":\"Hello World\",\"caller_id\":\"Joe user\"}");
var response = request.execute();
gs.log(response.getBody());

 

https://INSTANCENAME.service-now.com/now/nav/ui/classic/params/target/%24restapi.do

 

If helpful or correct, please indicate so!