Create incident with Script

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Please sign in to see details of an important advisory in our Customer Advisories area.

Create incident with Script

L2 Linker

Hi all,

I am creating an incident with script as following:

    uri = f'/incident'
    body = {
        "name": incident_name,
        "type": incident_type,
        "createInvestigation": True,
        #"rawJSON": json.dumps({'hello': 'test'})
    }
    return execute_command('demisto-api-post', {'uri': uri, 'body': body}, fail_on_error=False)

and i want to use a field that type is json. My purpose when i create an incident, i want to send args for playbook (if I give an input in rawjson, I can reach the result with the operations I will do here.) For example -> rawJSON: {"password":"defaultpassword"} and in playbook, I can get these on the playbook.

But rawJson doesn't work. Do you have any idea?

1 accepted solution

Accepted Solutions

L4 Transporter

Far as I know the /incident doesn't accept the rawJSON, you gotta build the body and send in the fields you want, example below.

 

Better option is to use /incident/json endpoint as this will accept a raw json body, and you and then add a Classifier and Mapper to it via Settings -> Objects Setup -> Incidents -> Classifiers and Mappers -> API Endpoints (3 dots on right side) -> Incident API. 


/incident/json body example:

body = {
"name": "json incident",
"type":"xsoar incident type",
"key1":"ready key one",
"key2":"ready key two"
}

 

/incident API body example

# body of the Incident, with all the fields we want to map.
# createInvestigation = True is required to have the playbook run automatically
body = {
"severity":1,
"owner":"admin",
"CustomFields": {
"eventtype":"Test API"
},
"type":"Unclassified",
"name":"Test Incident API",
"details":"This is a test",
"dbotcreated":"2012-10-27T15:41:55Z",
"createInvestigation": True
}

View solution in original post

1 REPLY 1

L4 Transporter

Far as I know the /incident doesn't accept the rawJSON, you gotta build the body and send in the fields you want, example below.

 

Better option is to use /incident/json endpoint as this will accept a raw json body, and you and then add a Classifier and Mapper to it via Settings -> Objects Setup -> Incidents -> Classifiers and Mappers -> API Endpoints (3 dots on right side) -> Incident API. 


/incident/json body example:

body = {
"name": "json incident",
"type":"xsoar incident type",
"key1":"ready key one",
"key2":"ready key two"
}

 

/incident API body example

# body of the Incident, with all the fields we want to map.
# createInvestigation = True is required to have the playbook run automatically
body = {
"severity":1,
"owner":"admin",
"CustomFields": {
"eventtype":"Test API"
},
"type":"Unclassified",
"name":"Test Incident API",
"details":"This is a test",
"dbotcreated":"2012-10-27T15:41:55Z",
"createInvestigation": True
}
  • 1 accepted solution
  • 978 Views
  • 1 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!