It's all about the answers!

Ask a question

Create defect with OSLC


Ivaylo Kubratov (132) | asked Jul 16, 12:03 p.m.
edited Jul 19, 9:09 a.m.

 I want to create defect using OSLC.

Using "OSLC-Core-Version=2.0" and "Accept=Application/RDF+XML"
From services I'm using "oslc:creation" link (from the image) to POST defect:

I have allowed value for each field.

Question1:
How can I find mandatory fields for each Project area?

Question2:
What is xml format for the body (context) of POST request?
I mean this format:

<oslc_cm:ChangeRequest
  rdf:about="">
  <dc:title>---title---</dc:title>
  <dc:type rdf:resource="---type---"/>
  <oslc_cm:severity rdf:resource="---severity---"/>
  <rtc_cm:com.howfound rdf:resource="---howfound---"/>
  <rtc_cm:foundIn rdf:resource="---foundIn---"/>
  <rtc_cm:com.Occurrence rdf:resource="---Occurrence---"/>
  <rtc_cm:filedAgainst rdf:resource="---filedAgainst---"/>
  <rtc_cm:plannedFor rdf:resource="---plannedFor---"/>
  <rtc_cm:com.workitem.defectc.defect.description>---description---</rtc_cm:com.workitem.defectc.defect.description>
</oslc_cm:ChangeRequest>


4 answers



permanent link
David Honey (3256) | answered Jul 16, 12:59 p.m.
JAZZ DEVELOPER

Discover the OSLC creation factory - see OSLC Core discovery.
The creation factory should reference an OSLC resource shape. That shape will tell you the supported properties.

Construct an RDF model conformant with the shape and POST using a supported RDF serialization form such as application/rdf+xml or text/turtle to the creation factory URI.


Comments
Ivaylo Kubratov commented Jul 19, 10:14 a.m. | edited Jul 19, 10:50 a.m.

 Yes I have the shape and all allowed values and I have CreationFactory for "creation of change requests", but can find there required properties to create defect, I don't want to use all available properties


David Honey commented Jul 19, 10:18 a.m.
JAZZ DEVELOPER

Look at the oslc:occurs of each OSLC property in the resource shape. That should tell you whether it is required.


Ralph Schoon commented Jul 19, 10:22 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I think you have to know the required properties that are imposed by EWM in the preconditions such as Required Attributes by type and state. I do not think that state dependent mandatory attributes are presented in the shape. I am not aware of a way to query this information. 


Ralph Schoon commented Jul 19, 10:26 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

From my own experience, the minimum information a work item requires to be created is a summary and the category (filed against). You can modify your process that the only required attribute is the subject/summary attribute, which is a string. 


The category is not a simple value and you would have to retrieve all the allowed values and you would have to pick one that is not the unassigned value. 


David Honey commented Jul 19, 10:28 a.m.
JAZZ DEVELOPER

Yes, that's true. I think that was part of what the old proposed OSLC Automation specification was going to address. But that specification fell by the way side and never reached published state, and now there seems little appetite for developing it into a public standard.


Ralph Schoon commented Jul 19, 10:30 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Also note, if you get a work item, you get valid values for one and you can remove the stuff you are not interested in. Once you have the values, you can easily create an XML with the ones you pick.  

showing 5 of 6 show 1 more comments

permanent link
Ralph Schoon (58.5k23642) | answered Jul 19, 3:48 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Please go to https://jazz.net/wiki/bin/view/Deployment/CLMProductAPILanding and check the links in the General OSLC section. At least look into the OSLC workshop.


permanent link
Ivaylo Kubratov (132) | answered Jul 20, 1:27 p.m.
edited Jul 20, 1:28 p.m.

 Thank you for all responses,

1. I'm try to create Defect with POST request to address, which I get from services
2. I get required properties from Defect shape
3. The request body is this:

<dc:title rdf:parseType="Literal">Test</dc:title>
<dc:description rdf:parseType="Literal">OSLC Creation Example</dc:description>
</rdf:RDF>
Status from this request is 403 Forbidden.
Can you tell me what is the reason for this response code?


permanent link
Ralph Schoon (58.5k23642) | answered Jul 21, 4:56 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I am not able to debug your code for you, there is not enough to work with. No information about the actual Request and URI, the request data is incomplete and likely uninteresting. The request headers URI and the response headers/body would be of interest for debugging. Anyway this is almost impossible in the forum. 


Note that a valid creation factory for a defect for me looks as follows: https://elm.example.com:9443/ccm/oslc/contexts/_8e5qfFpmEeukW7cqqDjAuA/workitems/defect 
 
I had a hard time learning this myself, so here some hints.

0. Use POSTMAN, RESTCLIENT, cURL or Python if you want to experiment.

1. The headers are absolutely critical, if you mess up the headers you fail. Important are OSLC-Core-Version: 2.0, Accept: application/rdf+xml, Content:  application/rdf+xml. 

2. You must be logged in - form based auth or basic auth. Session handling and Cookies are vital! See https://rsjazz.wordpress.com/2019/05/13/using-a-rest-client-to-authenticate-to-elm-clm-applications/

3. Be practical. Get a work item first (of the same type you want to create!). Then copy the Response body. Maybe remove the Work item ID from the RDF, you can try to leave it in as well and POST the response body to the factory URI. If you can create a work item that way, you can start looking at the resource shape and the request body you have now and strip unnecessary data away and to understand how to generate such a request body.  


Comments
Ralph Schoon commented Jul 21, 4:59 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Your answer


Register or to post your answer.