AnsweredAssumed Answered

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

Question asked by BalaKrishnab4 on Jun 15, 2017
Latest reply on Nov 9, 2017 by AbhishekDanej

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>"+


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