It's all about the answers!

Ask a question

How can I Update RTC Workitem of Attribute type ”String List” by REST API


HIROAKI JOSAKO (47430) | asked Oct 16 '17, 5:44 a.m.

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


Comments
Donald Nong commented Oct 17 '17, 12:44 a.m.

We had similar discussions in the past and it seems that there is no sure way to assign values in a "list" form - be it string list, enumeration list, and etc.


HIROAKI JOSAKO commented Oct 17 '17, 3:44 a.m.

Hi Donald!

Thank you for valuable information
It is very disappointing that Enumerations List can not be set....


Ian Wark commented Nov 01 '17, 4:05 a.m.

Enumeration list works. Still trying with String list. You may need to use the Match-If header with the ETag.

https://jazz.net/forum/questions/166325/how-update-rtc-work-item-with-enumeration-list-field-by-rest


HIROAKI JOSAKO commented Nov 01 '17, 4:41 a.m.

Hi lan
Thanks for infomations

Unfortunately, I did not understand well.
What is this ETag??

Umm..
Is there an example?
How to update list type


Donald Nong commented Nov 02 '17, 1:44 a.m. | edited Nov 02 '17, 1:44 a.m.

In the post that Ian provided, Dmitry updated the Enumeration List attribute only. Note the ?oslc_cm.properties=rtc_ext:com.finecosoft.components.field at the end of the URL he used. Maybe that's the trick.

ETag is to make sure that you have the current version of the work item. If someone else updates the work item after you GET it, ETag will change, and when you PUT to the work item with the previous ETag, it will fail (to prevent corruption).


HIROAKI JOSAKO commented Nov 06 '17, 1:59 a.m.

I understand that it will be retained by editing with another tag on change

showing 5 of 6 show 1 more comments

3 answers



permanent link
Ian Wark (79713553) | answered Nov 02 '17, 2:10 a.m.
edited Nov 02 '17, 2:48 a.m.

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.

Work Item To Update

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


permanent link
HIROAKI JOSAKO (47430) | answered Nov 06 '17, 1:59 a.m.

Thank you
I will give it a try.


permanent link
HIROAKI JOSAKO (47430) | answered Nov 26 '17, 11:53 p.m.

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
Ian Wark commented Nov 29 '17, 11:09 p.m.

Did you try using Firebug with Poster as per this example?
https://jazz.net/forum/questions/166922/how-to-use-firebug-and-poster-to-find-and-test-rest-parameters-to-change-workitems-in-rtc

There are other REST plugins which you can use, if you do not like that one.
http://restclient.net/


HIROAKI JOSAKO commented Dec 04 '17, 8:52 p.m.

>Did you try using Firebug with Poster as per this example?
https://jazz.net/forum/questions/166922/how-to-use-firebug-and-poster-to-find-and-test-rest-parameters-to-change-workitems-in-rtc

Yes, I tryed. Firebug,Poster,and RESTCLIENT
But,The output result was the same.

<rtc_ext:list_string1>[yeah!!, Booo]</rtc_ext:list_string1>


HIROAKI JOSAKO commented Mar 19 '18, 8:12 p.m.

Long time no see.
Again, it will be necessary so I will check it.
Regarding the method proposed by this case,

Ver 5.0.2 was nothing but a json format how- ever, but with version 6.0.2 and Request header set to txt rdf
It was able to output xml for each item.
You may be able to do the same thing.

Can you check if it can be realized with Ver 5.0.2?

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.