How to populate opened_at field when creating Incident using Rest API (POST)

Sergey Minsky
Kilo Contributor

POST https://instance.service-now.com/api/now/table/incident

{
    "opened_at": "javascript:gs.now()",
    "assignment_group":"Group",
    "category":"Network",
    "cmdb_ci":"Ci",
    "short_description":"Test REST API 2",
    "subcategory":"Other",
    "caller_id":"username"
}

 

How to specify current timestamp using POST Rest API

javascript:gs.now()  - doesn't do anything in that case

7 REPLIES 7

Harish Ragz
Kilo Guru

Once try to add opened_at field in 

find_real_file.png

 

Sergey Minsky
Kilo Contributor

Request

POST https://instance.service-now.com/api/now/table/incident?sysparm_fields=opened_at
Headers
Accept
 
application/json
Content-Type
 
application/json
 
Request Body
{
	"assignment_group":"AG",
	"category":"Network",
	"cmdb_ci":"CI",
	"short_description":"Test REST API 2",
	"subcategory":"Other",
	"caller_id":"user_id"
}

Response

 

201 Created

Headers
cache-control
 
no-cache,no-store,must-revalidate,max-age=-1
content-type
 
application/json;charset=UTF-8
date
 
Tue, 19 Jun 2018 15:48:04 GMT
expires
 
0
location
 
https://instance.service-now.com/api/now/table/incident/39e63165dbb257407e7867c35b961931
pragma
 
no-store,no-cache
server
 
ServiceNow
strict-transport-security
 
max-age=63072000; includeSubDomains
transfer-encoding
 
chunked
x-is-logged-in
 
true
Response Body

{ "result": { "opened_at": "" } }

try adding rest_service acl rule to write opened_at

find_real_file.png