Why is OSLC Query in Rational Team Concert not returning the expected result when I pass in specific parameters?
![]()
I have this query which works as expected: https://oslcqueryurl/?oslc.prefix=oslc_cm=<http://open-services.net/ns/cm%23>&oslc.where=oslc_cm:tracksChangeSet=<https://myserver/changesetId>
However, when I pass in additional parameters, it does not work as expected. 1) If I append &oslc.select=* or &oslc.select=dcterms:title to it, I do not get back any additional properties. From what I understood, &oslc.select=* is supposed to give back all the properties and &oslc.select=dcterms:title is supposed to give back the title of the work item. What did I do wrong with oslc.select? 2) Suppose I don't know the type of link, so I replaced oslc_cm:tracksChangeSet with *. It doesn't work and gives the error: Unknown attribute id [*]. What is the correct syntax? 3) In the OSLC query spec at http://open-services.net/bin/view/Main/OSLCCoreSpecQuery, I am supposed to be able to add or oslc_cm:tracksChangeSet=<https://myserver/changesetId2> to the above. But that gives an error. What is the correct way to use or? |
Accepted answer
![]()
You're almost there, just a couple of syntax problems. In general, for some good examples you could go to https://jazz.net/wiki/bin/view/Main/WorkItemAPIsForOSLCCM20. In particular the section Query Capabilities should help you in this case.
1) Querying for all or selected properties
Use no oslc.select for complete resources
https://oslcqueryurl/workitems
Append &oslc.select, the property AND the prefix URL for selecting individual properties
https://oslcqueryurl/workitems?oslc.select=dcterms:title&oslc.prefix=dcterms=%3Chttp%3A//purl.org/dc/terms/%3E
2) Discover what's supported
For some examples on how to discover the provider's capabilities go to Discovery Mechanism
3) OR operator in queries
The OR works with brackets, e.g., &oslc.where=cm:severity in ["high","medium"].
https://oslcqueryurl/workitems?oslc.where=cm:severity in ["high","medium"]&oslc.select=oslc_cm:severity
A common mistake im most query attempts is to forget to escape all URL components. The actual URL would look like https://localhost:9443/jazz/oslc/contexts/_f_vywF5XEeK9rd6rj1tVjA/workitems?oslc.where%3Dcm%3Aseverity%20in%20%5B%22high%22%2C%22medium%22%5D&oslc.select=oslc_cm:severity
HTH,
Jan.
W Diu selected this answer as the correct answer
Comments If operating in the OSLC v2 space, shouldn't we be asked for the query base resource and using that, e.g. (example taken from RM but same idea):
Whoops. If you oslcqueryurl means the URL at the queryBase then I get it. CCM and QM and RM have some web service inconsistencies and I incorrectly assumed oslcqueryurl was yet another means to get at the data (like the Requirements Reporting API)
Thanks for your reply, Jan, and especially for that link to the examples. It gives me a much better understanding of the expected syntax!
|