API to create incident ticket using servcienow api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2022 06:42 AM
HI,
I want to create incident ticket through servcienow API. Please suggest the POST api and request body.
- Labels:
-
Delegated Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2022 07:45 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2022 07:58 AM
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!