CA Service Management

  • 1.  Updating activity log for an incident through REST

    Posted Jul 17, 2017 05:26 AM

    I need to add an activity log to an existing incident through REST API. How can this be done. Documentation is no clear on how to update BREL attributes.

    The request I tried is the following but I keep getting "405 Method not allowed" for both PUT and POST

    So the question is, how do I add to activity log using REST?

     

    PUT /caisd-rest/in/595862/act_log HTTP/1.1
    Host: servicedesk.***.com
    X-AccessKey: 276789629
    X-Obj-Attrs: description
    Content-Type: application/xml
    Cache-Control: no-cache

    <in id="595862">
        <alg>
            <description>Updating log from Rest API</description>
        </alg>
    </in>



  • 2.  Re: Updating activity log for an incident through REST

    Posted Jul 17, 2017 05:31 AM

    The Service Desk Manager version is 14.1



  • 3.  Re: Updating activity log for an incident through REST
    Best Answer

    Broadcom Employee
    Posted Jul 19, 2017 11:19 AM

    Vid, try something like this

    ...

    String postBREL = baseURI + "/alg";

    String xmlPayload =
    "<alg>" +
    "<type REL_ATTR=\"LOG\"/>" +
    "<call_req_id REL_ATTR=\"" + mycrId + "\"/>" +
    "<description>my log from rest api</description>" +
    "</alg>";

    ...

    Thanks

    Chi



  • 4.  Re: Updating activity log for an incident through REST

    Posted Aug 28, 2017 03:26 AM

    This does indeed work when posted onhttps://localhost:8050/caisd-rest/alg and I see that the activity log gets created. Here is the response

     

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><alg id="6052404" REL_ATTR="alg:6052404" COMMON_NAME="Activity Log created from REST API Java Samples code"><link href="http://sdm.gdt.ms:8050/caisd-rest/alg/6052404" rel="self"/></alg>

     

    However, when the incident is queried for activity log, using an http GET

    on the following url,https://localhost:8050/caisd-rest/in/616601/act_log

    The newly added log, is not see. Neither is it seen from SDM UI.

    What could still be going wrong. Am I missing something.

    thanks.



  • 5.  Re: Updating activity log for an incident through REST

    Posted Jul 19, 2017 08:33 AM

    Hi Vidyadhar,

     

    Please have a look at the 'SampleCreateBRELResource.java' code in the samples folder.

     

    It demonstrates how to create a new record for a BREL attribute. In this sample, a new Log Comment activity is added to an existing Change Order. The same approach works for creating a new record for BLREL attributes.

     

    Kind Regards,
    Brian



  • 6.  Re: Updating activity log for an incident through REST

    Posted Aug 22, 2017 01:19 PM

    Thanks. for this information. The documentation also points to the same. Unfortunately I do not have access to an SDM server's file system where I can locate this file. Would be good if someone can actually post the code in this community.



  • 7.  Re: Updating activity log for an incident through REST

    Broadcom Employee
    Posted Aug 23, 2017 04:38 AM

    Hi Vidya,

     

    Hope this code helps for you

     

    ////////////////////////////////////////////////////////////////////////////
    // Copyright (c) 2011 CA.  All rights reserved.
    // 
    // This software and all information contained therein is confidential and
    // proprietary and shall not be duplicated, used, disclosed or disseminated
    // in any way except as authorized by the applicable license agreement,
    // without the express written permission of CA. All authorized
    // reproductions must be marked with this language. 
    //
    // EXCEPT AS SET FORTH IN THE APPLICABLE LICENSE AGREEMENT, TO THE EXTENT
    // PERMITTED BY APPLICABLE LAW, CA PROVIDES THIS SOFTWARE WITHOUT WARRANTY
    // OF ANY KIND, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF
    // MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT WILL
    // CA BE LIABLE TO THE END USER OR ANY THIRD PARTY FOR ANY LOSS OR DAMAGE,
    // DIRECT OR INDIRECT, FROM THE USE OF THIS SOFTWARE, INCLUDING WITHOUT
    // LIMITATION, LOST PROFITS, BUSINESS INTERRUPTION, GOODWILL, OR LOST DATA,
    // EVEN IF CA IS EXPRESSLY ADVISED OF SUCH LOSS OR DAMAGE.
    ///////////////////////////////////////////////////////////////////////////
    // $Id: $
    // Module     : SampleCreateBRELResource.java
    // Created    : 2012/04/13 15:50:24
    // Java Ver   : 1.6
    // Description:
    //
    ///////////////////////////////////////////////////////////////////////////
    //  README!  README!  README!  README!  README!  README!
    //
    // Description:
    //  This class file contains sample code for invoking Service Desk REST Web Services.
    //
    //  THIS SHOULD BE RUN IN A TEST ENVIRONMENT AGAINST A TEST SERVICE DESK SERVER!
    //  The routines in this file will create and modify Service Desk objects!
    //
    //  This sample class demonstrates how to create a new record for a BREL
    //  attribute and in particular, how to add a new Log Comment to a Change
    //  Order ticket.
    //
    //  The process for BLREL attributes is also the same. Create the record
    //  on the LREL resource, that is, the resource in the middle of the
    //  many-one-many relationship.
    //
    //  For example, chg.asset is a BLREL attribute and is defined as follows:
    //  asset   BREL <- lrel_asset_chgnr.chg (LREL nr) {chg = ?}
    //  To create a new relationship between a change order ticket and an asset,
    //  create a record in the lrel_asset_chgnr resource and provide the
    //  required attribute details.
    //
    //  For info on how to retrieve details from a BREL/BLREL attribute,
    //  see sample file SampleGetQRELDetails.java. The process is the same.
    //
    /////////////////////////////////////////////////////////////////////////

    import java.io.IOException;

    import org.apache.commons.httpclient.HttpClient;
    import org.apache.commons.httpclient.HttpException;
    import org.apache.commons.httpclient.methods.PostMethod;

    /**
     * This sample class demonstrates how to add a new Log Comment activity log
     * to an existing Change Order ticket.
     *
     * @author valre03
     * @version $Revision: ASPEN.0 $
     */
    public class SampleCreateBRELResource
    {
     @SuppressWarnings("deprecation")
     public SampleCreateBRELResource()
     {
      //--- CONFIGURABLE VARIABLES

       // REST API base URI
       String baseURI = "http://localhost:8050/caisd-rest";

       // The Access Key obtained during authentication
       String accessKey = "1174913924";

       // Change Order id
       String chgId = "400001";

      //--- END OF CONFIGURABLE VARIABLES


      HttpClient client = new HttpClient();

      ///////////////////////////////////////////////////////////////////
      // POST OPERATION -- Add a Log Comment activity to the Change Order
      ///////////////////////////////////////////////////////////////////

      String postBREL = baseURI + "/chgalg"; // Change Order Activity Log

      String xmlPayload =
       "<chgalg>" +
       "<type REL_ATTR=\"LOG\"/>" +
       "<change_id REL_ATTR=\"" + chgId + "\"/>" +
       "<description>Activity Log created from REST API Java Samples code</description>" +
       "</chgalg>";

      PostMethod post = new PostMethod(postBREL);
      post.addRequestHeader("X-AccessKey", accessKey);
      post.addRequestHeader("Accept" , "application/xml");
      post.addRequestHeader("Content-Type", "application/xml; charset=UTF-8");
      post.setRequestBody(xmlPayload);

      try {
       System.out.println("Execute POST request for " + postBREL);
       // Execute POST request
       int result = client.executeMethod(post);

       System.out.println("Response status code: " + result);
       System.out.println("Response body: ");
       System.out.println(post.getResponseBodyAsString());
       System.out.println();

      } catch (HttpException e) {
       e.printStackTrace();
      } catch (IOException e) {
       e.printStackTrace();
      } finally {
       post.releaseConnection();
      }

     }


     public static void main(String[] args)
     {
      new SampleCreateBRELResource();
     }
    }



  • 8.  Re: Updating activity log for an incident through REST

    Posted Aug 23, 2017 06:15 AM

    Thanks very much.

     

    Will try this.

     

    -Vidyadhar

     

    On Wed, Aug 23, 2017 at 2:08 PM, Maheshwar_Kusuma <