Query for specific tagged workitem by OSLC dcterms:subject
Hello,
I'm using the OSLC to fetch the expected tagged workitems with
| dcterms:subject in ["tvt","mustfix"] |
like format, which is one example in example6.
My URL is like
https://rb-alm-20-p.de.bosch.com/ccm/oslc/contexts/_QjsBsp5aEeq2u-M0ATM71Q/workitems/bugv2.0?oslc.where=dc:subject in ["stability"]&oslc.prefix=dcterms=<http://purl.org/dc/terms/>
and I do encode the URL by utf-8.But the response is still all the bugs without tag filter.
Does someone know how to fix this by OSLC or REST API of RTC?
2 answers
I assume you are using an OSLC query capability - see https://docs.oasis-open-projects.org/oslc-op/query/v3.0/os/oslc-query.html.
You should URL encode all the values for parameters including
oslc.where
and
oslc.prefix
. See the specification for details with examples.
Comments
I don't know where/how you got your query base URL but my 7.0.2 iFix009 test env doesn't have any query capability with bugv2.0 in it. YMMV.
For my test environment the project-specific work items query URL base for my project is https://jazz.ibm.com:9443/ccm/oslc/contexts/_pag-MkB1EeuDvqpPB-fV1g/workitems
This is discovered starting from rootservices, details after the Discovery heading below.
Then the full OSLC Query URL in this case for tags"asd" and "mobile":
With headers:
OSLC-Core-Version: 2.0
Accept: application/rdf+xml
With the encoding removed and with the query parameters broken out this looks like:
- oslc.prefix=dcterms=<http://purl.org/dc/terms/>
- oslc.where=dcterms:subject in ["asd","mobile"]
- oslc.select=*
- oslc.paging=true
- oslc.pageSize=200
The paging and pagesize are optional - but your code needs to be prepared for paging of results even if you don't specify these :-)
NOTE using oslc.select=* increases the load on the server so avoid if at all possible, to minimize the impact of your queries on users.
.
Discovery of OSLC Query base URL
I'm using 7.0.2 iFix009 - although AFAIK the steps below would work back to at least 6.0.2.
For all requests below you MUST provide headers:
* OSLC-Core-Version: 2.0
* Accept: application/rdf+xml
If you don't provide these headers then the sequence below won't work because you'll get different (non-OSLC 2.0) responses.
The querybases (there are two in my test environment) are in the project's services.xml., in my case this is at https://jazz.ibm.com:9443/ccm/oslc/contexts/_pag-MkB1EeuDvqpPB-fV1g/workitems/services.xml
You discover this starting from rootservices:
(this request doesn't require you to be authenticated)
Look for the entry:
<oslc_cm:cmServiceProviders
xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/"
rdf:resource="https://jazz.ibm.com:9443/ccm/oslc/workitems/catalog" />
Then:
(your client code will have to be authenticated to get the catalog and any other requests from now on, if your user doesn't have permission to access then you won't get the data)
This is the catalog of projects on your server. Find the project by looking for the dcterms:title tag with title of your project, then the services catalog for that project is in the rdf:about of the containing oslc:ServiceProvider tag:
<oslc:serviceProvider>
<oslc:ServiceProvider rdf:about="https://jazz.ibm.com:9443/ccm/oslc/contexts/_pag-MkB1EeuDvqpPB-fV1g/workitems/services.xml">
<dcterms:title rdf:parseType="Literal">My Project</dcterms:title>
<oslc:details rdf:resource="https://jazz.ibm.com:9443/ccm/process/project-areas/_pag-MkB1EeuDvqpPB-fV1g"/>
<jfs_proc:supportLinkDiscoveryViaLinkIndexProvider rdf:parseType="Literal">false</jfs_proc:supportLinkDiscoveryViaLinkIndexProvider>
<jfs_proc:supportContributionsToLinkIndexProvider rdf:parseType="Literal">true</jfs_proc:supportContributionsToLinkIndexProvider>
<jfs_proc:globalConfigurationAware rdf:parseType="Literal">compatible</jfs_proc:globalConfigurationAware>
<jazz_disc:messageReceiver rdf:resource="https://jazz.ibm.com:9443/ccm/web/com/ibm/team/workitem/web/EWMWorkitemsCopyHandler.html"/>
<jfs_proc:consumerRegistry rdf:resource="https://jazz.ibm.com:9443/ccm/process/project-areas/_pag-MkB1EeuDvqpPB-fV1g/links"/>
</oslc:ServiceProvider>
</oslc:serviceProvider>
Use the <oslc:ServiceProvider rdf:about="https://jazz.ibm.com:9443/ccm/oslc/contexts/_pag-MkB1EeuDvqpPB-fV1g/workitems/services.xml">
Then to find the correct query base URL search for an oslc:QueryCapability tag containing a tag oslc:resourceType for http://open-services.net/ns/cm#ChangeRequest, and the query base is the oslc:queryBase tag alongside it.
<oslc:queryCapability>
<oslc:QueryCapability>
<dcterms:title rdf:parseType="Literal">Change request queries</dcterms:title>
<oslc:usage rdf:resource="http://open-services.net/ns/core#default"/>
<oslc:resourceType rdf:resource="http://open-services.net/ns/cm#ChangeRequest"/>
<oslc:resourceShape rdf:resource="https://jazz.ibm.com:9443/ccm/oslc/context/_pag-MkB1EeuDvqpPB-fV1g/trs/shapes/workitems/query"/>
<oslc:queryBase rdf:resource="https://jazz.ibm.com:9443/ccm/oslc/contexts/_pag-MkB1EeuDvqpPB-fV1g/workitems"/>
</oslc:QueryCapability>
</oslc:queryCapability>
HTH
Ian