CA Service Management

  • 1.  how to create incident using REST API with location and department attributes

    Posted Jun 15, 2017 04:10 AM

    Hi Team,

     

    I was able to create the incident using REST api from Java class and here I was not able to populate the values for attributes location and department. But here I'm passing the values to REST API as shown below.

     

    String endpointPOST = baseURI + "/in";

      PostMethod post = new PostMethod(endpointPOST);
      post.addRequestHeader("X-AccessKey", getAccessID().toString());
      post.addRequestHeader("Accept" , "application/xml");
      post.addRequestHeader("Content-Type", "application/xml; charset=UTF-8");
      //post.addRequestHeader("X-Obj-Attrs" , "ref_num,requestor,summary, zdept");
      
      /*StringHolder NewRequestNumber = new StringHolder();
      StringHolder NewRequestHandle = new StringHolder();
      String attrVals[] = {"summary", "A new incident", "description", "new incident", "type", "crt:182"};
      client.createRequest(getAccessID().toString(), "", attrVals, "cr_tpl", NewRequestHandle, NewRequestNumber);  
         */ 
      
      /*String[] myArray=new String[]{"persid","ref_num","description","status","category","zdept","last_mod_dt"};
      String strDetails=client.doSelect(getAccessID().toString(),"in","",-1,myArray);
      */
      post.setRequestEntity(new StringRequestEntity(
       "<in>" +
       "<requestor id=\"711827\" COMMON_NAME=\"Requestor Name\" />"+
       "<customer REL_ATTR=\"U'000383AD1AAA71448BC7D52B35ABCD48'\"/>"+
       "<summary>Created from REST API Java code POST</summary>" +
       
       //"<requestor COMMON_NAME=\"IN27245780\"/>" +
       //"<requestor COMMON_NAME=\"AB\"/>"+
       
       //"<assignee REL_ATTR=\"U'637398407C765A49A0527381FDF197F5'\"/>"+
       //+ "User1</assignee>"+
         
       "<description>Description from REST API Java code</description>" +
         //"<priority id=\"500\" COMMON_NAME=\"3 - Low\"/>"+
       
       "<category id=\"669543\" COMMON_NAME=\"pcat:669543\"/>"+
       "<department id=\"1001128\" REL_ATTR=\"1001128\" COMMON_NAME=\"ETA - Internal\" />"+
       "<location id=\"03AE6B07863AEC4F8605BE7A6017E2D9\" REL_ATTR=\"loc:03AE6B07863AEC4F8605BE7A6017E2D9'\" />"+
          //"<priority COMMON_NAME=\"2 - Medium\"/>"+
       
          //  <priority id="500" REL_ATTR="1" COMMON_NAME="3 - Low">
          //+ "Medium</priority>" +
        //"<requestor COMMON_NAME=\"711827\"/>" +
        //"<requestor rel=\"self\"/>"+
       
        // "<status id=\"5200\" COMMON_NAME=\"Open\" />"+

       // "<group id=\"U'3DB0E17B891FC84B85EA493EB467F6FE'\"/>"+
         //"<status COMMON_NAME=\"Closed\"/>"+
         // "</status>"+
       "</in>"
        
      ));

     

    Can you please help me how to populate the incident with location and department.



  • 2.  Re: how to create incident using REST API with location and department attributes

    Posted Jun 15, 2017 08:44 AM

    Hi Balakrishna, 

    What is the message that comes back when you attempt to do this?  Does it throw any errors in the console or in the logs?  (check REST and stdlogs on SDM).

    I just ran a "bop_sinfo -a in" to see the attributes for the incident object and it seems that its not actually an attribute on that object.    I even looked at the OOTB incident form and it doesnt have department or location on it. Can you tell me which fields you are attempting to populate specifically?

    Thanks,

    Jon I.



  • 3.  Re: how to create incident using REST API with location and department attributes

    Posted Nov 09, 2017 03:56 AM

    Thanks for the tips Jon, I've just started working on REST API for incident creation ..your tips will surely come handy.



  • 4.  Re: how to create incident using REST API with location and department attributes

    Posted Jun 15, 2017 09:06 AM

    Hi Jon, Thanks for the information. Here did not get any error while creating incident. Incident is created but values passing for location and department attributes are not populated.

    When I saw the Incident creation manually in CA Service Desk, I observed that two mandatory fields Department and Location are showing in UI.

    Hence I'm trying to populate values for these two attributes from my rest api like how we are passing value for customer attribute.



  • 5.  Re: how to create incident using REST API with location and department attributes

    Posted Jun 15, 2017 10:49 AM

    My guess is that those are custom fields that were added to the form in your case.  Those are not there out of the box.  Take a look at the detail_in.htmpl form and search for Department and Location - see what the actual attribute is that those fields point to.  I am willing to bet its a "z_" field - which was added to the incident object as a custom field.  Also you can run "bop_sinfo -a in > sinfo_in.txt" and then paste that here - i am guessing there is a custom field showing on there for each of those.

    Let me know,

    Jon I.



  • 6.  Re: how to create incident using REST API with location and department attributes

    Broadcom Employee
    Posted Jun 20, 2017 03:35 AM

    Hi BalaKrishna,

    Excerpt from bop_sinfo  on IN should gives more details on department and location fields.

    If these fields are of any relation to other table then you need to provide its subsequent id .

    ~Vinod.