REST API to create Work Item in RTC

2 answers

I hinted in https://jazz.net/forum/questions/275433/to-find-all-project-areas-in-rtc-using-rest-apipostman to follow https://jazz.net/wiki/bin/view/Deployment/CLMProductAPILanding and do the https://jazz.net/library/article/635 Not sure if that was done.
You would discover the work item service: See https://jazz.net/wiki/bin/view/Main/WorkItemAPIsForOSLCCM20#Discovery_Mechanism and also see https://jazz.net/wiki/bin/view/Main/ResourceOrientedWorkItemAPIv2#Discovery
From there you get what you need. The sequence looks like this:
Rootservices:
Request GET https://elm.example.com:9443/ccm/rootservices
Request GET https://elm.example.com:9443/ccm/rootservices
Catalog (Project Areas)
Request GET https://elm.example.com:9443/ccm/oslc/workitems/catalog
Request GET https://elm.example.com:9443/ccm/oslc/workitems/catalog
Project Area service descriptor for one project area
Request GET https://elm.example.com:9443/ccm/oslc/contexts/_8e5qfFpmEeukW7cqqDjAuA/workitems/services
Get creation Factory for the type
Resource Shape for the work item type of one project area
Request GET https://elm.example.com:9443/ccm/oslc/context/_8e5qfFpmEeukW7cqqDjAuA/shapes/workitems/
Request GET https://elm.example.com:9443/ccm/oslc/context/_8e5qfFpmEeukW7cqqDjAuA/shapes/workitems/
Resource Shape defines available attributes and the allowed values for attributes
Get details for complex values (Category, Target, Enumerations) following the links
Example Category “unassigned” see "dcterms:title": "Unassigned"
Request GET https: //elm.example.com:9443/ccm/resource/itemOid/com.ibm.team.workitem.Category/_8s97oVpmEeukW7cqqDjAuA
Example Category “unassigned” see "dcterms:title": "Unassigned"
Request GET https: //elm.example.com:9443/ccm/resource/itemOid/com.ibm.team.workitem.Category/_8s97oVpmEeukW7cqqDjAuA
Compose the Request body with the attributes needed for the work item and post
Request POST https://elm.example.com:9443/ccm/oslc/contexts/_8e5qfFpmEeukW7cqqDjAuA/workitems/defect
Body:
{"dcterms:title": "Work Item Created from JSON in Python.", "dcterms:description": "This is a work item linking to <a href=\"https://jazz.net/\">Jazz.net</a>.", "rtc_cm:filedAgainst": {"rdf:resource": "https://elm.example.com:9443/ccm/resource/itemOid/com.ibm.team.workitem.Category/_HWNLMFpnEeukW7cqqDjAuA", "rdf:type": [{"rdf:resource": "http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/Category"}]}}
Body:
{"dcterms:title": "Work Item Created from JSON in Python.", "dcterms:description": "This is a work item linking to <a href=\"https://jazz.net/\">Jazz.net</a>.", "rtc_cm:filedAgainst": {"rdf:resource": "https://elm.example.com:9443/ccm/resource/itemOid/com.ibm.team.workitem.Category/_HWNLMFpnEeukW7cqqDjAuA", "rdf:type": [{"rdf:resource": "http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/Category"}]}}