Property Values when creating a ticket via Web Services
search cancel

Property Values when creating a ticket via Web Services

book

Article ID: 431467

calendar_today

Updated On:

Products

CA Service Desk Manager CA Service Management - Service Desk Manager

Issue/Introduction

The following article discusses populating property values that come from a Category while creating a new Request/Incident/Problem via web services.

In the examples given, the following properties are defined for a Test Category.

Environment

Release:  17.4 and above
CA Service Desk Manager

Resolution

For CXF SOAP Web Services:

You can use the createRequest method, which contains the propertyValues parameter.  The idea here is to list the values of each property sequentially.  

The following example illustrates such a call being performed when creating an Incident for the above category definition:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://www.ca.com/UnicenterServicePlus/ServiceDesk">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:createRequest>
         <sid>XXXX</sid>
         <creatorHandle>cnt:XXXX</creatorHandle>
         <attrVals>
            <!--Zero or more repetitions:-->
           <string>summary</string>
           <string>Test</string>

           <string>description</string>
           <string>TestSoap</string>

           <string>category</string>
           <string>pcat:XXXX</string>

           <string>customer</string>
           <string>cnt:XXXX</string>

           <string>assignee</string>
           <string>cnt:XXXX</string>

           <string>type</string>
           <string>I</string>
         </attrVals>

         <propertyValues>
            <!--Zero or more repetitions:-->
            <string>test from SOAP</string>
            <string>Red</string>
            <string></string>
            <string>Yes</string>
         </propertyValues>

         <template></template>
         <attributes>
            <!--Zero or more repetitions:-->
            <string>ref_num</string>
         </attributes>
         <!--Optional:-->
         <newRequestHandle></newRequestHandle>
         <!--Optional:-->
         <newRequestNumber></newRequestNumber>
      </ser:createRequest>
   </soapenv:Body>
</soapenv:Envelope>


Replace XXXX with appropriate values, mainly ID values for the corresponding parameter.  

The resultant ticket created will show this list of populated properties:

 

For REST Web Services.

This is a two stage process. Create the initial request/incident/problem, naming the Category, then populate the properties associated with the selected Category or Area

First, perform a POST to the in (incident) object.  

POST:  http://SDM-SERVER:8050/caisd-rest/in


JSON Code Body used to create the incident:

{
    "in": {
        "customer": {
            "@COMMON_NAME": "ServiceDesk"
        },
        "assignee": {
            "@COMMON_NAME": "ServiceDesk"
        },
        "category": {
            "@COMMON_NAME": "Test Category"
        },
        "description": "Test Ticket REST",
        "priority": {
            "@COMMON_NAME": 3
        },
        "summary": "Test Summary",
    }
}

In the above, the category of interest is "Test Category", which contains the property definition per the introductory screenshot.

Second, perform a PUT call to the cr_prp object to update the properties.  This will need to be done for each property value, which can be obtained, first by obtaining the incident persid, then by doing a GET call on the cr_prp object to collect the id values that correspond to the incident, matching the incident's persid to the cr_prp.owning_cr attribute. 

For instance:

GET:  http://SDM_SERVER:8050/caisd-rest/in?WC=ref_num='XX'


This will return the persid value, "cr:XXXX" for the ticket based on the above ref_num (enter actual incident ticket number for the highlighted entry)

GET:  http://SDM_SERVER:8050/caisd-rest/cr_prp?WC=owning_cr='cr:XXXX'


This will return the id values for all of the properties associated with the owning incident.

The following is an example PUT call that can be made to the cr_prp object, against an example cr_prp entry with id 400087

PUT:  http://SDM-SERVER:8050/caisd-rest/cr_prp/400087
{
    "cr_prp": {
        "value": "test from REST"
    }
}

Additional calls will need to be made per property.  

PUT:  http://SDM-SERVER:8050/caisd-rest/cr_prp/400088
{
    "cr_prp": {
        "value": "Blue"
    }
}

The resultant ticket created will show this list of properties.  Only the first two properties were modified, with no values populated per property during initial ticket creation:

Additional Information

For SOAP, if a given property is marked as required or mandatory, and no value is entered, the property will be populated with a single "-" character.

For REST, it is not possible to create a payload to create a new ticket and populate the property values in a single call.  This is due to REST operations working on a per object call basis, that is a given REST call works off of a single object at a time.  Additionally, the properties attribute for the cr/in/pr objects involve a BREL relationship with documented limitations for REST.  Such functionality in turn limits REST from handling mandatory property values when creating tickets. 

See also:  Adding a Request Area or Category Properties to a ticket created via REST call