Rest API to fetch certain components from GCM project area (Filtering of components based on modified / created date)date
![]()
Thiruvenkadam Dhanaraj (27●2●18)
| asked Feb 20 '22, 10:31 p.m.
retagged Feb 23 '22, 3:34 a.m. by Ian Barnard (2.0k●6●13) Hi,
I need to get all components of a GCM project area based on modified date.
i had tried to use the GCM api filter to get components using query-base?oslc.where=dcterms:modified<date> but i am able to fetch only a specific component with exact timestamp.
Is there any option to fetch components between date1 and date2 (delta)?
Kindly suggest me an api for the above query.
Thanks & Regards,
Thiru
|
Accepted answer
![]()
Ian Barnard (2.0k●6●13)
| answered Feb 21 '22, 3:46 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Feb 21 '22, 5:45 a.m.
Hi
> query-base?oslc.where=dcterms:modified<date>
Your oslc.where syntax isn't correct, but maybe you've typed pseudo-query ;-)
The below queries work - I double-checked them using 7.0.2.
The (unencoded) correct form for such a query would be, for example:
or to query for components modified between two dates
I've shown examples using UTC/GMT (as denoted by the Z) - TBH I'm not sure what the timezone support of GCM is (DOORS Next only supports UTC/GMT), although as GCM provides data in UTC/GMT I suspect tit will only compare with UTC/GMT. See the docs for what GCM supports here https://jazz.ibm.com:9443/gc/doc/page?pluginId=com.ibm.team.gc.service&relativePath=doc%2Fapi/OslcQuery.html UPDATE: I tried without Z and GCM assumes the date is in the server timezone.
Encoded the second query would look like:
The query capabilities of GCM are very nicely documented on your own server at https://SERVER:PORT/gc/doc/page?pluginId=com.ibm.team.gc.service&relativePath=doc%2Fapi/OslcQuery.html and pages linked from there, for example for components https://SERVER:PORT/gc/doc/page?pluginId=com.ibm.team.gc.service&relativePath=doc%2Fapi/QueryComponents.html
If you still can't get your query to work you should edit into your question the complete URL you're using, the headers you're sending and the full response headers and body you receive. Below is an example of just that - NOTE in the details below the response Content-Length won't match the XML because I replaced for SERVER:PORT and pretty-printed the XML. In the project being queried there are three components, one older than the earlier date, so only two results are returned. I included oslc.select=* so you can see the dcterms:modified date and the other properties for these components
HTH
Ian
GET https://SERVER:PORT/gc/oslc-query/components/_AekBQUB5EeuruP931CHJDw?oslc.pageSize=200&oslc.paging=true&oslc.select=%2A&oslc.where=dcterms%3Amodified%3E%222022-01-01T21%3A51%3A40.979Z%22+and+dcterms%3Amodified%3C%222022-03-01T21%3A51%3A40.979Z%22 HTTP/1.1
Host: SERVER:PORT
User-Agent: python-requests/2.26.0
Accept-Encoding: gzip, deflate, br
Accept: application/rdf+xml
Connection: keep-alive
X-Requested-With: XMLHttpRequest
Referer: https://SERVER:PORT/gc/web
OSLC-Core-Version: 2.0
net.jazz.jfs.owning-context: https://SERVER:PORT/gc/process/project-areas/_AekBQUB5EeuruP931CHJDw
Cache-Control: no-cache
Cookie: JAZZ_AUTH_TOKEN=bb87e0dda79c482dacf493fed05dfd41&Q4QM40nWyS9GN5QOKXgarRLfl4yLMoOR9qE0Uo65wM; jfs-oauth-access-token0=bb87e0dda79c482dacf493fed05dfd41; jfs-oauth-access_token-secret0=Q4QM40nWyS9GN5QOKXgarRLfl4yLMoOR9qE0Uo65wM; JSESSIONID=0000UaNcU4kLZIOx266YVPrtFG9:27ae0d33-ba3a-41b9-adf8-1446e883f923; LtpaToken2=Wvv008KrgBvDls/a+ewAsvVMTUVC2JCX9/CWMk+ZnVDVjFOSrzPBs3uCZc/awVezAqef3geqizYuQ+HZq3VuEMTtBNgbn+5zwTZsxlVP8dO5OhEm7o01p+I8W1D3tXPE9GMNCXUyuT2wdIghQIQRQY2kjCb5Q0X9BbwLkGTUerLCk7tWMmdWwqKVeXgnIBqGBDewyXrQ5S6qGI2m507HCQhL2R+GADrtr/4ev4Avnt5KG2/VbxKymHIdFQW3mO//2z3ZcS87PG6WFWWdt27F9ZQ6YGwR9yGMFypTX7Yfrd/Xo1UhRgMzW6QmTHDW4r4G
HTTP/1.1 200 OK
X-Powered-By: Servlet/3.0
Strict-Transport-Security: max-age=31536000
Set-Cookie: JAZZ_AUTH_TOKEN=bb87e0dda79c482dacf493fed05dfd41&Q4QM40nWyS9GN5QOKXgarRLfl4yLMoOR9qE0Uo65wM; Path=/gc; Secure; HttpOnly
Cache-Control: no-cache
Pragma: no-cache
x-robots-tag: nofollow
Allow: GET
Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel=type,<http://www.w3.org/ns/ldp#Resource>; rel=type
ETag: d96c62c0-350b-40bc-9f4e-12c534cd45fa
Last-Modified: Mon, 21 Feb 2022 09:01:23 GMT
Cache-Control: no-store
Cache-Control: must-revalidate
Expires: 0
Content-Type: application/rdf+xml; charset=UTF-8
Content-Language: en-US
Date: Mon, 21 Feb 2022 09:01:23 GMT
Content-Length: 4529
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:gclocal_type_datatype="https://SERVER:PORT/gc/type/datatype/"
xmlns:j.0="http://www.w3.org/ns/ldp#"
xmlns:gclocal_type_attribute="https://SERVER:PORT/gc/type/attribute/"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:gclocal_type_artifact="https://SERVER:PORT/gc/type/artifact/"
xmlns:gc="http://jazz.net/ns/gc#"
xmlns:process="http://jazz.net/ns/process#"
xmlns:oslc_acc="http://open-services.net/ns/core/acc#"
xmlns:oslc_config_ext="http://jazz.net/ns/config_ext#"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:oslc="http://open-services.net/ns/core#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:prov="http://www.w3.org/ns/prov#"
xmlns:oslc_config="http://open-services.net/ns/config#"
xmlns:gclocal_type_link="https://SERVER:PORT/gc/type/link/"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:oslc_auto="http://open-services.net/ns/auto#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rtc_cm="http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/" >
<rdf:Description rdf:about="https://SERVER:PORT/gc/component/7">
<process:projectArea rdf:resource="https://SERVER:PORT/gc/process/project-areas/_AekBQUB5EeuruP931CHJDw"/>
<oslc_acc:accessContext rdf:resource="https://SERVER:PORT/gc/acclist#_AekBQUB5EeuruP931CHJDw"/>
<dcterms:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2022-02-21T08:34:35.181Z</dcterms:created>
<dcterms:title rdf:parseType="Literal">newest</dcterms:title>
<oslc:shortId>7</oslc:shortId>
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2022-02-21T08:34:35.228Z</dcterms:modified>
<oslc:instanceShape rdf:resource="https://SERVER:PORT/gc/type/artifact/_A2jqhkB5EeuruP931CHJDw/shape"/>
<oslc:serviceProvider rdf:resource="https://SERVER:PORT/gc/oslc-config/serviceProvider/_AekBQUB5EeuruP931CHJDw"/>
<rdf:type rdf:resource="http://open-services.net/ns/config#Component"/>
<dcterms:description rdf:parseType="Literal"/>
<oslc_config:configurations rdf:resource="https://SERVER:PORT/gc/component/7/configurations"/>
<dcterms:identifier>_GVPR4JLxEeyBKuFyPjtEMw</dcterms:identifier>
<oslc:archived rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</oslc:archived>
<dcterms:creator rdf:resource="https://SERVER:PORT/jts/users/me"/>
<dcterms:contributor rdf:resource="https://SERVER:PORT/jts/users/me"/>
</rdf:Description>
<rdf:Description rdf:about="https://SERVER:PORT/gc/component/6">
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2022-02-10T08:32:28.953Z</dcterms:modified>
<oslc_config:configurations rdf:resource="https://SERVER:PORT/gc/component/6/configurations"/>
<oslc:archived rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</oslc:archived>
<oslc:shortId>6</oslc:shortId>
<dcterms:identifier>_2e3HAIpIEeyjBK67jk4xcg</dcterms:identifier>
<oslc_acc:accessContext rdf:resource="https://SERVER:PORT/gc/acclist#_AekBQUB5EeuruP931CHJDw"/>
<dcterms:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2022-02-10T08:10:04.032Z</dcterms:created>
<dcterms:description rdf:parseType="Literal"/>
<rdf:type rdf:resource="http://open-services.net/ns/config#Component"/>
<oslc:instanceShape rdf:resource="https://SERVER:PORT/gc/type/artifact/_A2jqhkB5EeuruP931CHJDw/shape"/>
<oslc:serviceProvider rdf:resource="https://SERVER:PORT/gc/oslc-config/serviceProvider/_AekBQUB5EeuruP931CHJDw"/>
<dcterms:title rdf:parseType="Literal">~!@#$%^&()_+:<>?;'\</dcterms:title>
<process:projectArea rdf:resource="https://SERVER:PORT/gc/process/project-areas/_AekBQUB5EeuruP931CHJDw"/>
<dcterms:contributor rdf:resource="https://SERVER:PORT/jts/users/me"/>
<dcterms:creator rdf:resource="https://SERVER:PORT/jts/users/me"/>
</rdf:Description>
<rdf:Description rdf:about="https://SERVER:PORT/gc/oslc-query/components/_AekBQUB5EeuruP931CHJDw">
<oslc:resourceShape rdf:resource="https://SERVER:PORT/gc/oslc-query/shape/container/components"/>
<j.0:contains rdf:resource="https://SERVER:PORT/gc/component/6"/>
<j.0:contains rdf:resource="https://SERVER:PORT/gc/component/7"/>
<rdf:type rdf:resource="http://www.w3.org/ns/ldp#BasicContainer"/>
</rdf:Description>
</rdf:RDF>
Thiruvenkadam Dhanaraj selected this answer as the correct answer
Comments ![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
In additional to the excellent info that Ian has provided above....
It almost never makes sense to query for a date-time value with equals. As you found out, this will only find resources whose property has that exact date-time value (which might have resolution milliseconds). Likewise, it rarely makes sense to test a floating point value equals some floating point literal. You almost always want to test that it is within a range of values. This applies to all properties with date-time values, including
dcterms:created
, and
dcterms:modified
, regardless of the application..
|
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.
Comments
Thank you Ian and David. This solution worked for me. Thank you very much :)