Creating a ticket via template through REST Web Services
search cancel

Creating a ticket via template through REST Web Services

book

Article ID: 376694

calendar_today

Updated On:

Products

CA Service Desk Manager CA Service Management - Service Desk Manager

Issue/Introduction

This article discusses the complexities of creating a ticket (request/incident/problem) through a pre-defined template

Environment

Service Desk Manager/CMDB 12.9 or higher on Windows/Unix/Linux

Cause

It is not possible to leverage the native functionality of the templates with creating a ticket through REST.  That functionality being the fields and other pertinent data that are contained in the template is automatically copied over into the new ticket.

Comparing with the webengine/web interface and REST web services:

  • Webengine performs a single call to create an incident from a given template, however, there are also functionalities that are part of the webengine architecture and design which facilitates field copy/transfer from the template over to the new incident.

  • REST web services strictly functions per object call.  The POST action on the "in" object will require population of the necessary fields, which is not automatically done when templates are involved, and does not have access to the webengine functionality which could copy such field data across.

Resolution

The following is a workaround one may try to follow to create a ticket through a template via REST.  It is a manual process which simulates the activity across several REST calls.  The overall procedure obtains the given fields from the template and the original ticket that the template is based off of, then creates a new ticket based on those values. 

Unlike the webengine based functionality, REST will not automatically transfer any omitted field data from the template to the new ticket.  If the summary field is left out, this method will not populate the field automatically from the source template.  The summary field data needs to be populated as part of the REST call to create the ticket.

  • Step 1:  Make a GET call to http://SDM-SERVER:8050/caisd-rest/cr_tpl/56789 by passing X-Obj-Attrs header as template. (Assuming 56789 is the incident template Id we want to create ticket from)
    • The response for this would be -------"template": {

                     "@id"12345,

                     "@REL_ATTR""cr:12345",             <== THIS IS THE ACTUAL TICKET ID which is the template

                     "@COMMON_NAME"55,

                     "link": {

                     "@href""http://SDM-SERVER:8050/caisd-rest/cr/12345",

                     "@rel""self"

                 }

  • Step 2:  Make a GET call to http://HOSTNAME:8050/caisd-rest/in/12345 with X-Obj-Attrs as * or fields of interest to include for a new ticket in third step 
    (
    summary,description,category,priority,assignee,group,urgency,impact,affected_resource,symptom_code,resolution_code,resolution_method,caused_by_chg,external_system_ticket)

    XXXX is the UUID of the given CI that needs to be included in the ticket, in this case, TestCI.
    YYYY is the UUID of the given contact designated as the assignee, in this case, the ServiceDesk user

    • The response for this would be -----"affected_resource": {

                       "@id""U'XXXX'",

                       "@REL_ATTR""U'XXXX'",

                       "@COMMON_NAME""TestCI",

                       "link": [

                       {

                          "@href""http://SDM-SERVER:8050/caisd-rest/nr/U'XXXX'",

                          "@rel""self"

                       },

                      {

                         "@href""http://SDM-SERVER:8050/caisd-rest/har_serx/U'XXXX'",

                         "@rel""extension"

                      }

                  ]

                 },

                 "assignee": {

                    "@id""U'YYYY'",

                    "@REL_ATTR""U'YYYY'",

                    "@COMMON_NAME""ServiceDesk",

                    "link": {

                         "@href""http://SDM-SERVER:8050/caisd-rest/agt/U'YYYY'",

                         "@rel""self"

                   }

              },.........................

  • Step 3:  Make a POST call to create ticket http://SDM-SERVER:8050/caisd-rest/in with the values from previous call. 
    Note:  None of the values from the previous calls will be transferred automatically into the new incident in the way the webengine does when creating an incident from a template.  
    • The sample POST Body should be ---- {

                      "in": {

                          "customer": {

                             "@COMMON_NAME""ServiceDesk"

                          },

                         "base_template": {

                              "@REL_ATTR""cr:12345"

                         },

                         "affected_resource": {

                              "@COMMON_NAME""TestCI"

                         },

                        "assignee": {

                             "@COMMON_NAME""ServiceDesk"

                        },--------

Additional Information

In the above, steps 1 and 2 are gathering information about the template and the original incident which the template is based off of.  Step 3 is where you need to populate all of the values from Steps 1 and 2, including the summary and description fields and any other fields which need to transfer across from the template.  The webengine was designed to perform this task automatically per its design.  REST, being that it is operating on an object basis, does not have the ability to leverage the webengine to perform the field data transfer.  Simply specifying just the "base_template" attribute in the REST call in step 3 will not result in field data transfer from the template, as one would find in webengine. 

Further, the resultant incident created via REST will not have the Initial Activity Log entry that reads as "Create request from template 'XXXX'".  The initial activity log will simply read as "Create a new request/incident/problem/change/issue".  

Sample-376694.json attached to this KB Article illustrates the above functionality.  You can use a 3rd party REST testing product such as Postman to test.

Broadcom Support is not permitted to assist in developing any custom code.  The attached code and the above document is provided as-is for reference and is not intended for use in a production instance.  Please try the above in a testing instance.

SOAP Web Services supports the creation of a new incident via template, and functions the same as the webengine functionality.  Please see how to create an incident from an existing template

Attachments

Sample-376694.json get_app