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

Mike Patel
Tera Sage

opened_at is auto populated so you don't have pass that in. Remove it and try.

Unfortunately it doesn't

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

 

BODY

 

 

201 Created Result

 

 

 

Unfortunately it doesn't

 

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

BODY

{
    "assignment_group":"AG",
    "category":"Network",
    "cmdb_ci":"CI",
    "short_description":"Test REST API 2",
    "subcategory":"Other",
    "caller_id":"user_id"
}

201 Created

{
    "result": {
        "upon_reject": "cancel",
        "sys_updated_on": "2018-06-19 14:11:47",
        "u_affected_cis": "093a66566fa54600b79acd6f1e3ee4dc",
        "number": "INC3630824",

   "u_approval_reminder_counter": "0",
        "state": "1",
        "sys_created_by": "user_id",
        "knowledge": "false",
        "cmdb_ci": {
            "link": "https://instance.service-now.com/api/now/table/cmdb_ci/093a66566fa54600b79acd6f1e3ee4dc",
            "value": "093a66566fa54600b79acd6f1e3ee4dc"
        },
        "impact": "4",
        "active": "true",
        "work_notes_list": "",
        "priority": "5",
        "short_description": "Test REST API 2",
        "work_start": "",
        "notify": "1",
        "sys_class_name": "incident",
        "closed_by": "",
        "escalation": "0",
        "upon_approval": "proceed",
        "u_assignment_group_changes": "true",
        "sys_updated_by": "user_id",
        "opened_by": {
            "link": "https://instance.service-now.com/api/now/table/sys_user/21e1dcbcdb5ef200ee19f3651d961929",
            "value": "21e1dcbcdb5ef200ee19f3651d961929"
        },
        "sys_created_on": "2018-06-19 14:11:46",

        "opened_at": "",

I tried your raw code in REST API Explorer and I see opened_at is set. Try doing it in your REST API Explorer and see if you get same response.

 

find_real_file.png