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
Comments
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.
Hi Donald!
Thank you for valuable information
It is very disappointing that Enumerations List can not be set....
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
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
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).
I understand that it will be retained by editing with another tag on change