-1

I am creating an incident via web service by reading incident json data from a txt file. The incident gets created but the incident number field is empty in the generated incident in my instance(Fiji). I am setting the incident number in the input json data. I wanted to know if we can specify the incident number in the input json data or have the table auto generate the incident number. Regards, Priyank

pri_dev
  • 11,315
  • 15
  • 70
  • 122

1 Answers1

0

I was curious about your question so I went ahead a tried making a rest call with just the description in the data payload to see what would happen

var requestBody = "{'description':'oh boy'}"; 
var client=new XMLHttpRequest();
client.open("post","https://scdevelopment.service-  now.com/api/now/table/incident");

client.setRequestHeader('Accept','application/json');
client.setRequestHeader('Content-Type','application/json');

//Eg. UserName="admin", Password="admin" for this code sample.
client.setRequestHeader('Authorization', 'Basic '+btoa('DELETED'+':'+'DELETED'));

client.onreadystatechange = function() { 
if(this.readyState = this.DONE) {
    document.getElementById("response").innerHTML=this.status +       this.response; 
}
}; 
client.send(requestBody);

Here is the default JavaScript help from the REST API Explorer. You can see I am just sending a requestBody with the description field.

And here's the response I get

{"result": {
"skills": "",
"upon_approval": "proceed",
"location": "",
"expected_start": "",
"reopen_count": "0",
"close_notes": "",
"additional_assignee_list": "",
"impact": "3",
"urgency": "3",
"correlation_id": "",
"sys_tags": "",
"sys_domain": {
  "link": "DELETED",
  "value": "global"
},
"description": "oh boy",
"group_list": "",
"priority": "5",
"delivery_plan": "",
"sys_mod_count": "0",
"work_notes_list": "",
"business_service": "",
"follow_up": "",
"closed_at": "",
"sla_due": "",
"delivery_task": "",
"sys_updated_on": "2016-02-28 22:16:26",
"parent": "",
"work_end": "",
"number": "INC0010233",
"closed_by": "",
"work_start": "",
"calendar_stc": "",
"u_votes": "0",
"category": "",
"business_duration": "",
"incident_state": "1",
"activity_due": "",
"correlation_display": "",
"company": {
  "link": "DELETED"
},
"active": "true",
"due_date": "",
"assignment_group": "",
"caller_id": {
  "link": "DELETED",
  "value": "ef04eb560f46c240d0db715be1050e59"
},
"knowledge": "false",
"made_sla": "true",
"comments_and_work_notes": "",
"parent_incident": "",
"state": "1",
"user_input": "",
"sys_created_on": "2016-02-28 22:16:26",
"approval_set": "",
"reassignment_count": "0",
"rfc": "",
"child_incidents": "0",
"opened_at": "2016-02-28 22:16:26",
"short_description": "",
"order": "",
"sys_updated_by": "aj.siegel",
"resolved_by": "",
"notify": "1",
"upon_reject": "cancel",
"approval_history": "",
"problem_id": "",
"work_notes": "",
"calendar_duration": "",
"close_code": "",
"sys_id": "69258f6e133d5200ca3db1676144b01a",
"approval": "not requested",
"caused_by": "",
"severity": "3",
"sys_created_by": "aj.siegel",
"resolved_at": "",
"assigned_to": "",
"business_stc": "",
"wf_activity": "",
"cmdb_ci": "",
"opened_by": {
  "link": "DELETED",
  "value": "ef04eb560f46c240d0db715be1050e59"
},
"subcategory": "",
"rejection_goto": "",
"sys_class_name": "incident",
"watch_list": "",
"time_worked": "",
"contact_type": "phone",
"escalation": "0",
"comments": ""
 }
}

Notice "number": "INC0010233",

Yay, autogenerated incident number.

Stegel
  • 11
  • 5