It's all about the answers!

Ask a question

How to use oslc.query in the RTC RESTful simply query interface


1
1
Dave Sinclair (21179) | asked Mar 06 '15, 4:28 a.m.
I am trying to write some Perl code to use the RESTful interface on RTC to access workitems.  I am able to get the simpl_query_services URI as described in https://jazz.net/library/article/1001 and  https://jazz.net/wiki/bin/view/Main/WorkItemAPIsForOSLCCM20.   When I use the basic URI, eg

https://myjazzserver.com:9443/jazz/oslc/contexts/_8IloQGRKEeGMeeKcLm-Fsg/workitems

then all seems to work well and I get a collection of workitems returned (in fact all the workitems in the Project).  However, I have not been able to work out how to do a 'where' query to select a subset of these workitems, eg

https://myjazzserver.com:9443/jazz/oslc/contexts/_8IloQGRKEeGMeeKcLm-Fsg/workitems?oslc.where=dc:identifier="1832"

again returns all the workitems in the project.  In fact, whatever I put in the where clause seems to have absolutely no effect.  Can anyone say what the correct syntax is for these types of queries?  I want to be able to do queries based on id and also on workitem type, which seems to be a more complex resource type.  For instance we have a workitem type called 'build' in our project,  and i would like to be able to find all the workitems of that type.  The type is indicated in the workitem description by elements such as

<dc:type rdf:resource="https://jazz201.hursley.ibm.com:9443/jazz/oslc/types/_8IloQGRKEeGMeeKcLm-Fsg/build"/>

so how should I construct a query to find all these items - i tried

https://myjazzserver.com:9443/jazz/oslc/contexts/_8IloQGRKEeGMeeKcLm-Fsg/workitems?oslc.where=dc:type="build"

but this does not work.  How does the oslc_prefix parameter play in all of this?

Any help or examples greatly appreciated.

3 answers



permanent link
Harald Freyer (11) | answered Nov 03 '15, 8:08 a.m.
In other articles (e.g. https://jazz.net/forum/questions/89876/can-i-use-work-item-type-as-query-parameter-in-reportable-rest-api) I have found the hint that workItemType is something like a "complex" attribute and one needs to use on its "id". For me, this olsc.where expression worked (I replaced my type with your "build" type)
oslc.where=workItemType%2Fid%3D%22build%22
(decoded: oslc.where=workItemType/id="build")

permanent link
Aaron Cabrera (451318) | answered Mar 06 '15, 2:00 p.m.
edited Mar 06 '15, 2:26 p.m.

In our environment - we can use the URI for Work Item Types

https://myjazzserver.com:9443/jazz/oslc/types/_8IloQGRKEeGMeeKcLm-Fsg/

It will retrieve the xml of all the work item types in the project area

This snippet is for work item type Story

  Work Item Type Story

Notice dcterms:identifier = com.ibm.team.apt.workItemType.story

Use com.ibm.team.apt.workItemType.story in the oslc.where clause

List of Stories
https://myjazzserver.com:9443/jazz/oslc/contexts/_8IloQGRKEeGMeeKcLm-Fsg/workitems?oslc.where=rtc_cm:type="com.ibm.team.apt.workItemType.story"
 
List of Stories with Attributes
https://myjazzserver.com:9443/jazz/oslc/contexts/_8IloQGRKEeGMeeKcLm-Fsg/workitems?oslc.where=rtc_cm:type="com.ibm.team.apt.workItemType.story"&oslc.select=dcterms:type,dcterms:identifier,dcterms:type,rtc_cm:type
  
You can also get the Work Item Type ID (dcterms:identifier) by going into :

Manage This Project Area -> Work Items -> Types and Attributes: use the ID associated with the Work Item Type


permanent link
Aaron Cabrera (451318) | answered Mar 06 '15, 11:01 a.m.
edited Mar 06 '15, 11:04 a.m.

I'm new to oslc but here is an example that works for me

?oslc.where=dcterms:identifier=1832&oslc.select=dcterms:identifier,dcterms:title,oslc_cm:status,dcterms:contributor,oslc_cm:closed
	

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.