通过servicenow中的webservice创建事件而不创建事件编号

时间:2016-02-18 23:43:52

标签: servicenow

我通过读取txt文件中的事件json数据,通过Web服务创建事件。事件已创建但事件编号字段在我的实例(斐济)中生成的事件中为空。我在输入的json数据中设置事件编号。我想知道我们是否可以在输入的json数据中指定事件编号,或者让表格自动生成事件编号。 问候, Priyank

1 个答案:

答案 0 :(得分:0)

我很好奇你的问题,所以我继续尝试用数据有效负载中的描述进行休息调用,看看会发生什么

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);

以下是REST API Explorer的默认JavaScript帮助。你可以看到我只是发送一个带有描述字段的requestBody。

这是我得到的回应

{"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": ""
 }
}

注意"number": "INC0010233",

是的,自动生成的事件编号。