How can I Update RTC Workitem of Attribute type ”String List” by REST API
Hi
I would like to update the attribute of type "STRING LIST".
example:
curl -D workitem\header.txt -k -b %COOKIES% -o workitem\createlog.html -H "Content-Type: application/rdf+xml" -H "Accept: application/rdf+xml " -H "OSLC-Core-Version: 2.0" -X PUT -d @wi12345.xml %HOST%"/oslc/workitems/12345"
in xml
<?xml version="1.0" ?><rdf:RDF xmlns:ns1="http://purl.org/dc/terms/" xmlns:ns2="http://open-services.net/ns/cm#" xmlns:rtc_ext="http://jazz.net/xmlns/prod/jazz/rtc/ext/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="https://rtcserver/ccm/oslc/workitems/12345">
<rtc_ext:list_string1>[aaaaaa,bbbbb]</rtc_ext:list_string1>
</rdf:Description>
</rdf:RDF>
but It fails when it is executed. It will be "500 Err"
Statuscode500 ”Incorrect JSON array:” [aaaaaa,bbbbb]
Please thanks
3 answers
This can be done. I have just confirmed.
Here are my steps.
I created a string list in a defect type work item with name MyStringList and added some strings.
1. $ ./curlAuth.sh
This is the content of that script..
COOKIES=./cookies.txt
USER=clmadmin
PASSWORD=clmadmin
HOST="https://<my-ip>:9443/ccm"
curl -k -c $COOKIES "$HOST/authenticated/identity"
curl -k -L -b $COOKIES -c $COOKIES -d j_username=$USER -d j_password=$PASSWORD "$HOST/authenticated/j_security_check"
2. URL=https://<my-ip>:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/2
3. curl -D - -k -b cookies.txt -o "wi-005.json" -H "Content-Type: application/rdf+xml" -H "Accept: application/rdf+xml " -H "OSLC-Core-Version: 2.0" $URL
HTTP/1.1 200 OK
X-Powered-By: Servlet/3.0
x-com-ibm-team-scenario: <some_ip>
ETag: "75720c2a-5be6-3bbf-b137-2490d1ea9f40"
Last-Modified: Thu, 02 Nov 2017 05:19:08 GMT
Cache-Control: private, max-age=0, must-revalidate
Expires: Thu, 02 Nov 2017 05:25:48 GMT
OSLC-Core-Version: 2.0
Vary: Accept, OSLC-Core-Version
Content-Type: application/rdf+xml;charset=UTF-8
Transfer-Encoding: chunked
Date: Thu, 02 Nov 2017 05:25:48 GMT
4. Now open the wi-005.json data and add a line with syntax similar to the other lines:
<rtc_ext:MyStringList rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Cat</rtc_ext:MyStringList>
5. curl -D - -k -b cookies.txt -H "Content-Type: application/rdf+xml" -H "Accept: application/rdf+xml " -H "OSLC-Core-Version: 2.0" -X PUT --data-binary @wi-005.json $URL
6. Refresh the work item and find a new string added to the string list called "Cat". You can add and remove items in the list by adding or removing lines. The rows in the json data come asynchronously, so I don't think it matters exactly which line you add to.
BTW The ETag is not required after all. But for the record, the ETag (entity tag) is defined as "an HTTP response header returned by an HTTP/1.1 compliant web server used to determine change in content at a given URL." It is returned from the REST GET request. It can be used for caching and for conditional requests. There is a little explanation here: http://www.baeldung.com/etags-for-rest-with-spring
I tried it over and over but I could not acquire the above XML.
String list type is retrieved as a string in json format.
This RTC uses Ver. 5.0.2 ifix 19.
example
一部抜粋です。
rtc_ext:list_string1がstring list型のデータです。
個々のデータで取 得せず、json型になっています。
<rdf:RDF xmlns:dcterms="http://purl.org/dc/terms/" xmlns:oslc_cm="http://open-services.net/ns/cm#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rtc_ext="http://jazz.net/xmlns/prod/jazz/rtc/ext/1.0/" xmlns:oslc_cmx="http://open-services.net/ns/cm-x#" xmlns:acp="http://jazz.net/ns/acp#" xmlns:rtc_cm="http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/" xmlns:oslc="http://open-services.net/ns/core#" xmlns:oslc_pl="http://open-services.net/ns/pl#" >
<rdf:Description rdf:about="https://jazz/ccm/resource/itemName/com. ibm.team.workitem.WorkItem/568498">
<rtc_cm:estimate rdf:datatype="http://www.w3. org/2001/XMLSchema#long"></rtc_cm:estimate>
<rtc_ext:customer.id rdf:datatype="http://www.w3. org/2001/XMLSchema#string"></rtc_ext:customer.id>
<rtc_cm:progressTracking rdf:resource="https: //jazz/ccm/oslc/workitems/_ZyfuUJ82EeeoXLVe6p0UuQ/progressTracking"/>
<dcterms:title rdf:parseType="Literal">Test</dcterms:title>
<oslc_cm:fixed rdf:datatype="http://www.w3. org/2001/XMLSchema#boolean">false</oslc_cm:fixed>
<oslc_cm:status rdf:datatype="http://www.w3. org/2001/XMLSchema#string">New</oslc_cm:status>
<oslc:shortTitle rdf:parseType="Literal">Issue 568498</oslc: shortTitle>
<rtc_cm:modifiedBy rdf:resource="https://jazz/jts/users/josako. hiroaki"/>
<rtc_ext:model rdf:resource="https: //jazz/ccm/oslc/enumerations/_Vp3hoD1rEeSWrYGan499dg/enum_model/enum_mod el.literal.l1"/>
<rtc_cm:due rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime" >2017-11-06T03:00:00.000Z</rtc_cm:due>
<rtc_ext:list_string1>[yeah!!, Booo]</rtc_ext:list_string1>
<oslc_pl:schedule rdf:resource="https: //jazz/ccm/oslc/workitems/_ZyfuUJ82EeeoXLVe6p0UuQ/schedule"/>
<oslc_cm:verified rdf:datatype="http://www.w3. org/2001/XMLSchema#boolean">false</oslc_cm:verified>
<rtc_ext:issue.category2 rdf:resource="https: //jazz/ccm/oslc/enumerations/_Vp3hoD1rEeSWrYGan499dg/enum_issue. category2/enum_issue.category2.literal.l2"/>
<rtc_cm:state rdf:resource="https: //jazz/ccm/oslc/workflows/_Vp3hoD1rEeSWrYGan499dg/states/com.ibm.team. workitem.issueWorkflow/com.ibm.team.workitem.issueWorkflow.state.s1"/>
<dcterms:modified rdf:datatype="http://www.w3. org/2001/XMLSchema#dateTime">2017-11-06T08:10:13.259Z</dcterms:modified>
</rdf:Description>
</rdf:RDF>
Is not there anything to worry about?
Comments
Donald Nong
Oct 17 '17, 12:44 a.m.HIROAKI JOSAKO
Oct 17 '17, 3:44 a.m.Ian Wark
Nov 01 '17, 4:05 a.m.HIROAKI JOSAKO
Nov 01 '17, 4:41 a.m.Donald Nong
Nov 02 '17, 1:44 a.m.HIROAKI JOSAKO
Nov 06 '17, 1:59 a.m.