It's all about the answers!

Ask a question

Can I use REST API to create a workitem in Complete/Closed status at once?

Anselme Joseph (133) | asked Apr 10 '17, 5:10 p.m.

 I am using RESTClient in Firefox to create Workitems in RTC. (library versions 6.0.3)

POST Request to Create workitem <o:p> </o:p>

POST : https://localhost:9443/ccm/oslc/contexts/_GEcakBVmEee6xq3fftABNg/workitems/task <o:p> </o:p>

Headers: <o:p> </o:p>

Header Name           |                                                                  Header Value <o:p> </o:p>

Accept                        |                      application/rdf+xml <o:p> </o:p>

OSLC-Core-Version  |                      2.0 <o:p> </o:p>

Content-Type            |                      application/rdf+xml <o:p> </o:p>

X-Jazz-CSRF-Prevent |                    JSESSIONID=00001IGA1EZ4wPHrGt-easJjnqs:f37b2418-3d73-415b-a35f-856e07d94d28; path=/ccm; domain=localhost; Secure; HttpOnly <o:p> </o:p>















<dcterms:title rdf:parseType="Literal">NEW REST API POST Sample Work Item</dcterms:title>

<dcterms:description>Status IP Task Created from HTTP POST request</dcterms:description>

<rtc_cm:type rdf:resource="https://localhost:9443/ccm/oslc/types/_GEcakBVmEee6xq3fftABNg/task"/>

<rtc_cm:filedAgainst rdf:resource="https://localhost:9443/ccm/resource/itemOid/"/>

<rtc_cm:plannedFor rdf:resource="https://localhost:9443/ccm/oslc/iterations/_GRjpghVmEee7sYeSp0HetA"/>

<oslc_cmx:priority rdf:resource="https://localhost:9443/ccm/oslc/enumerations/_GEcakBVmEee6xq3fftABNg/priority/priority.literal.l11"/>

<oslc_cmx:project rdf:resource="https://localhost:9443/ccm/oslc/projectareas/_GEcakBVmEee6xq3fftABNg"/>

<dcterms:contributor rdf:resource="https://localhost:9443/jts/users/myadmin"/>

<rtc_cm:resolvedBy rdf:resource="https://localhost:9443/jts/users/myadmin"/>

<rtc_cm:state rdf:resource="https://localhost:9443/ccm/oslc/workflows/_GEcakBVmEee6xq3fftABNg/states/"/>



This works fine to create a "New" task, except that the tickets that I will be migrating as tasks into RTC are already closed. Is is possible via REST APi, in one shot, to create the tickets, setup the status as "Complete" as well as populate resolvedBy, closeDate, ResolutioDate? 
The only other option that I see is to : Create the tasks as "New", then query the workitems and update the status and the Resolution attributes.

One answer

permanent link
Donald Nong (14.5k614) | answered Apr 13 '17, 6:04 a.m.

If really necessary, you can try to temporarily modify the workflow to suit. If I understand correctly, when you create a work item, the Start Action (usually is Initialize, whose target state is New) is called. Maybe you can choose the action, say Resolve, as the Start Action, temporarily.

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.