How update RTC work item with enumeration list field by REST
I found an unclear issue. I can not update an RTC work item which contains a multi value field created based on enumeration list attribute.
If I use a single enumeration, for example priority, so I can do GET request to this work item and define a real value like to:
<oslc_cm:priority rdf:resource="https://jazz.finecosoft.ru:9443/ccm/oslc/enumerations/_LbHV8FaWEeSZl8cZf7qI_w/priority/Critical"/>
In this case, I know that I will use the value in "rdf:resource" attribute to change the field value.
But what can I to do in case of multi value custom field. The value which I get with REST is like to:
<rtc_cm:com.finecosoft.components.field oslc_cm:collref="https://jazz.finecosoft.ru:9443/ccm/oslc/enumerations/_LbHV8FaWEeSZl8cZf7qI_w/enumerationList$com.finecosoft.components.enum"/>
I don't see the values which are set for this field. Please help me if it's possible to work with enumeration list by REST API.
Thank you very much in advance!
Accepted answer
From what I see you can use the Firebug to check how it works, see the post:
https://jazz.net/forum/questions/135858/how-to-perform-particular-action-using-rest-api-in-clm-applications
Best regards,
Tad
Comments
Hi Tadeusz,
Thank you for your reference! I couldn't find it earlier.
Firebug shew me such POST data which I can reproduce in my code:
additionalSaveParameters com.ibm.team.workitem.common.internal.updateBacklinks
attributeIdentifiers com.finecosoft.components.field
attributeValues ["com.finecosoft.components.enum.literal.l2","com.finecosoft.components.enum.literal.l4","com.finecosoft.components.enum.literal.l6","com.finecosoft.components.enum.literal.l8"]
itemId _mcFNcFtuEeSOSZ_ecNriAA
projectAreaItemId _LbHV8FaWEeSZl8cZf7qI_w
sanitizeHTML true
stateId _uD-9gFtvEeSOSZ_ecNriAA
type com.finecosoft.workitem.type.requestbat
We can see a correct syntax in "attributeValues", and other useful data. I will return here soon for finalizing the investigation results.
1 vote
Hi Dmitry,
I added a simple example how use Firebug and Poster in situations like yours, please see the post:
https://jazz.net/forum/questions/166922/how-to-use-firebug-and-poster-to-find-and-test-rest-parameters-to-change-workitemss-in-rtc
Hi Tad,
Thank you for the reference above. To update such field with HTTP request in XML format (not JSON) I performed in accordance to OSLC CM v2.0:
1. Do GET request:
URL: https://<SERVER>:9443/ccm/oslc/workitems/136?oslc_cm.properties=rtc_ext:com.finecosoft.components.field
Headers:
OSLC-Core-Version: 2.0
Accept: application/rdf+xml
Content-Type: application/rdf+xml
Response from server:
<rdf:RDF>
<rdf:Description rdf:about="https://<SERVER>:9443/ccm/oslc/workitems/136?oslc_cm.properties=rtc_ext:com.finecosoft.components.field">
<rdf:type rdf:resource="http://open-services.net/ns/cm#ChangeRequest"/>
<rtc_ext:com.finecosoft.components.field rdf:resource="https://<SERVER>:9443/ccm/oslc/enumerations/_LbHV8FaWEeSZl8cZf7qI_w/enumerationList$com.finecosoft.components.enum/SPM"/>
<rtc_ext:com.finecosoft.components.field rdf:resource="https://<SERVER>:9443/ccm/oslc/enumerations/_LbHV8FaWEeSZl8cZf7qI_w/enumerationList$com.finecosoft.components.enum/IBS"/>
<rtc_ext:com.finecosoft.components.field rdf:resource="https://<SERVER>:9443/ccm/oslc/enumerations/_LbHV8FaWEeSZl8cZf7qI_w/enumerationList$com.finecosoft.components.enum/Homer"/>
</rdf:Description>
</rdf:RDF>
I found in headers of the response:
Etag: 36d19b16-2364-3c38-aac6-176636921543
Current screenshot for the custom field:
- Do PUT request:
URL: the same
Headers: the same
and
If-Match: 36d19b16-2364-3c38-aac6-176636921543
This value is taken from Etag in response headers from GET request!
Data Body:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:oslc_cm="http://open-services.net/ns/cm#"
xmlns:rtc_ext="http://jazz.net/xmlns/prod/jazz/rtc/ext/1.0/" >
<rdf:Description rdf:about="https://<SERVER>:9443/ccm/oslc/workitems/136?oslc_cm.properties=rtc_ext:com.finecosoft.components.field">
<rdf:type rdf:resource="http://open-services.net/ns/cm#ChangeRequest"/>
<rtc_ext:com.finecosoft.components.field rdf:resource="https://<SERVER>:9443/ccm/oslc/enumerations/_LbHV8FaWEeSZl8cZf7qI_w/enumerationList$com.finecosoft.components.enum/TW"/>
<rtc_ext:com.finecosoft.components.field rdf:resource="https://<SERVER>:9443/ccm/oslc/enumerations/_LbHV8FaWEeSZl8cZf7qI_w/enumerationList$com.finecosoft.components.enum/UFO"/>
</rdf:Description>
</rdf:RDF>
We can see at the next screenshot that the enumeration list is actually updated!
I believe this info could help to everybody who needs the details of updating the enumeration list fields with HTTP requests!