[closed] Setting Result Details of RQM Test Result using OSLC API
Hello.
Can someone provide an example of how to write inside the Result Details of the Test Result section using the OSLC API?
I tried to recreate the structure of extended Properties I have seen inside a Test Result I fetched from ETM using the API, but something might be missing.
I am trying with this code and when I check in ETM the Test Result is created and it looks ok but the Result Details section is empty.
Dictionary<QName, object> extProp = new Dictionary<QName, object>();
QName qName = new QName("http://jazz.net/ns/qm/rqm", "richTextSession","rqm_qm");
List<AnyResource> anyResources= new List<AnyResource>();
AnyResource anyResource = new AnyResource();
IDictionary<QName, object> insideExtProp = new Dictionary<QName, object>();
QName detailsContent = new QName("http://jazz.net/ns/qm/rqm", "content", "rqm_qm");
string content = "Details Content";
QName detailsTitle = new QName("http://purl.org/dc/terms/", "title", "dcterms");
string dTitle = "Notes";
QName detailsIdentifier = new QName("http://purl.org/dc/terms/", "identifier", "dcterms");
string identifier = "com.ibm.rqm.execution.editor.section.tcResultNotes";
insideExtProp.Add(detailsContent, content);
insideExtProp.Add(detailsIdentifier, identifier);
insideExtProp.Add(detailsTitle, dTitle);
anyResource.SetExtendedProperties(insideExtProp);
anyResource.SetTypes(new List<Uri>() { new Uri("http://jazz.net/ns/qm/rqm#RichTextSection") });
anyResources.Add(anyResource);
extProp.Add(qName, anyResources);
testResult.SetExtendedProperties(extProp);
String testResultCreation = client.LookupCreationFactory(
serviceProviderUrl, OSLCConstants.OSLC_QM_V2,
testResult.GetRdfTypes()[0].ToString());
HttpResponseMessage testResultCreationResponse = client.CreateResource(
testResultCreation, testResult,
OslcMediaType.APPLICATION_RDF_XML);
I would be amazingly grateful for any advice.
The question has been closed for the following reason: "The question is answered, right answer was accepted" by rschoon May 04 '23, 7:09 a.m.
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 03 '23, 2:52 a.m.I can not provide an example that would fit your example. I can only provide with approaches that have helped me.
To create a test case I had to provide the title, the description, the RDF.type and the suspect state. Once you can do it there, you can write an app for it.
Catalin Morcan
May 03 '23, 9:35 a.m.Thank you for responding.
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 03 '23, 9:43 a.m.You assume that the API has to directly return the same data you see in the UI. I can assure you here and right now, that this is definitely a wrong assumption. Dependent on which API and which part of the API, you might only get links/references to other stuff. If you need the details about the linked element, you need to do another GET to get it.
OSLC (assuming this is the OSLC API) works based on resources and links between resources. The resource contains its attributes. Basic attributes such as text strings are directly returned in the resource. Complex items like links to other items or enumerations, you would have to GET to get at the values.
Catalin Morcan
May 03 '23, 10:20 a.m.Ok. And then if I understand it right I should try a GET operation on the link that I pasted in the comment above.
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 03 '23, 10:27 a.m.I would try to GET that resource. I do not know if OSLC would or would not consider this as an OSLC resource or not. I am not an ETM OSLC expert, I just did some examples.
Without further investigation I can even not say if you are using OSLC QM API. You send the headers, that is for sure, but the URI'S are not exposed so I couldn't tell if I wanted.
If you used RESTClient in Firefox and authenticated against the RM, you could just paste the reference URI in there, add the headers and try to GET the resources.
Note POST is different and requires additional headers e.g. X-Jazz-CSRF-Prevent.
Catalin Morcan
May 03 '23, 10:34 a.m.I tried it with Postman and this is what I got
Catalin Morcan
May 03 '23, 10:34 a.m.And these were the headers I used:
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 04 '23, 2:01 a.m.URL is missing. The return is an HTML page with a redirect. So something is wrong. Authenticated?
Catalin Morcan
May 04 '23, 2:26 a.m.Yes. I am authenticated.
Ian Barnard
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 04 '23, 4:06 a.m.In the browser you're using RESTClient, make sure you are logged in to your server. Also the response is HTML - you probably need to add header Accept: application/rdf+xml to your GET so the result is XML RDF
1 vote
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 04 '23, 4:34 a.m.See https://rsjazz.wordpress.com/2019/05/13/using-a-rest-client-to-authenticate-to-elm-clm-applications/
Catalin Morcan
May 04 '23, 6:08 a.m.The header was the issue, I thought I already had it, but I was wrong.