It's all about the answers!

Ask a question

OSLC REST API: How to set a "drop down list" attribute programmatically, for ex: "Severity", for a RTC WI.


Khader Basha (1113) | asked Sep 16 '15, 8:48 a.m.
edited Sep 18 '15, 9:02 a.m.

Below is the code used to construct Work item programmatically. 

     String sStartOSLC = "<oslc_cm:ChangeRequest";
  String sEndOSLC = "</oslc_cm:ChangeRequest>";
        String xmlNS =  " xmlns:dc=\"http://purl.org/dc/terms/\"   xmlns:rtc_cm=\"https://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/\"  xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"  xmlns:oslc_cm=\"http://open-services.net/xmlns/cm/1.0/\" xmlns:oslc_cmx=\"http://open-services.net/ns/cm-x#\">";
        String sType = "<rtc_cm:type rdf:resource=\""+sType_data+"\"/>";       
        String sTitle = "<dc:title>"+"A New Defect for OSLC_5"+"</dc:title>";
        String sSeverity = "<oslc_cmx:severity>"+"severity.literal.l3"+"</oslc_cmx:severity>";       
        String sPriority = "<oslc_cmx:priority>"+"priority.literal.l3"+"</oslc_cmx:priority>";
        String sProjectArea = "<dc:projectarea>"+"Test RTC (Project)"+"</dc:projectarea>";
        String steamArea = "<dc:teamarea>"+"Test RTC (Project)"+"</dc:teamarea>";
        String sDescrption = "<dc:description>"+"OSLC Rest Service Test Defect Creation_5"+"</dc:description>";       
              
          String sOslcXML = sStartOSLC+xmlNS+sTitle+sType+sSeverity+sPriority+sProjectArea+steamArea+sDescrption+sEndOSLC;
        HttpEntity myEntity = new StringEntity(sOslcXML);
  httppost.setEntity(myEntity);

Using the above code I am able to create a workitem programmatically. The problem is only Text area fields like Title, Description are populated but it could not populate Drop down values like Severity,

One answer



permanent link
Donald Nong (14.4k314) | answered Sep 27 '15, 11:19 p.m.
You need to understand what these dropdown fields really are in order to update them correctly using OSLC. "Severity" is an enumeration, and FiledAgainst is a category, for both the value has to be the full resource URL. You'd better do a GET first and examine the response body carefully before doing a PUT or POST. Go through the tutorial first and always refer back to the wiki.
https://jazz.net/library/article/1001
https://jazz.net/wiki/bin/view/Main/WorkItemAPIsForOSLCCM20

Comments
Khader Basha commented Sep 28 '15, 6:12 a.m.

Thank you Donald.

Your answer


Register or to post your answer.