demisto-py - Specify Playbook

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

demisto-py - Specify Playbook

L0 Member

Hello All,

 

I have a python script using demisto-py that creates tickets based on an input Word document.

 

However, specifying the playbook isn't working.  

 

When I call demisto_client.demisto_api.CreateIncidentRequest() with the "playbookid" field is populated with the Playbook name, as found in Playbooks page.   I thought this field invoked the playbook in older versions of my script, but I may be incorrect.

 

When I create the incident via create_incident(),  "playbookid" isn't present, but "playbook_id" is, and it is empty.  The case is created fine, but in the context data, "playbookid" is an empty string.  "playbook_id" is not present.

 

Changing the field name to "playbook_id" I get a "Item not found" error and the case isn't created.  You'd think playbook_id is the field to use as that is the field used by default and is listed in one of the examples on github.  But, I've never gotten it to work.

 

Any ideas?  Am I missing something?

2 REPLIES 2

L3 Networker

Can you share the script you are using? There are 2 invocations of create incident. One using a single incident creation with specific fields and the other using JSON.

Thank you for taking the time to reply.

 

Here is the relevant part (the script is fairly long and involved, and the rest doesn't come into play) : 

 

    # Create ticket request object
    oTicket = demisto_client.demisto_api.CreateIncidentRequest()

    # Write common case data
    oTicket.name = sCaseNum.split(' ')[0]
    for k, v in dBase.items() :
        setattr(oTicket, k, v)

    # Write the custom fields to the case
    setattr(oTicket, 'custom_fields', dCustom)

    try :
        # Create the incident
        api_response = oAPI.create_incident(create_incident_request=oTicket)
        # Parse the returned data
        iCreatedId = api_response.to_dict().get('id')

 

Prior to this, the script gathers all relevant data, either through an input Word document or by prompting the user.  The data has been split into two Python dictionaries - one for the base fields and one for the custom_fields.

 

Once this function has the data, it attaches it to the case (oTicket) via setattr.  It then creates the case and saves the case number.

 

No other fields have issues, so I think the coding is solid.  It is just this one - I get conflicting hints on whether it should be playbookid or playbook_id.

I'm at a loss, but need to figure this out because I want to be able to arbitrarily run playbooks when this script runs.

  • 2599 Views
  • 2 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!