How to get the value of Owned by attribute using HTTP Client Query method(Custom Java implementation)?
![]() Hi,
We are trying to get a custom workitem type named Release Schedule and it's attributes details using HTTP Client Query method and the headers are "Content-Type", "application/Json", "OSLC-Core-Version", "2.0", "Accept", "application/Json".
The application version is 6.0.6.1 with iFix027.
We are writing a HTTP Client Query to fetch field Ownedby by using dcterms:contributor.
Query:
String workitemUrl = cnfprop.getWebContextUrl() + "/oslc/contexts/_JSWgwaSqEeqGIaAO2lNttQ/workitems?"
+"oslc.where=rtc_cm:type=%22com.ibm.team.workitem.workItemType.p6%22&oslc.select=dcterms:contributor,rtc_cm:filedAgainst";
But while fetching we are getting this parser exception, but for other attribute like filedagainst we are getting output but for owned by we are unable to get the output.
We are getting this Parser Exception
org.apache.wink.json4j.JSONException: Expecting '{' on line 1, column 6 instead, obtained token: 'Token: String - 'Error''
at org.apache.wink.json4j.internal.Parser.parseObject(Parser.java:193)
at org.apache.wink.json4j.internal.Parser.parse(Parser.java:130)
at org.apache.wink.json4j.internal.Parser.parse(Parser.java:95)
at org.apache.wink.json4j.JSONObject.<init>(JSONObject.java:138)
at com.test.Query.getfiledAgainst(Query.java:740)
at com.test.Query.main(Query.java:162)
Could you Please help on this how to get ownedby attribute value.
Thanks. |
3 answers
![]()
Ralph Schoon (62.0k●3●36●43)
| answered Feb 08, 6:43 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER We had a similar question recently. The answer was to use application/rdf-xml as content type and accept and not JSON. |
![]()
David Honey (1.4k●1●7)
| answered Feb 08, 7:04 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Feb 08, 7:12 a.m. If you are using OSLC related REST services, such as OSLC query, you should use a supported RDF media type. OSLC and Linked Lifecycle data is about RDF. Data is interchanged using RDF serialization formats such a RDF/XML or Turtle. Commonly supported RDF media types include
Note that
application/json
is not an RDF media type. While some ELM application REST services might support it, the JSON representation is not defined by OSLC. Clients doing so are likely to become dependent on proprietary and undocumented JSON representations. You can represent RDF as json using
JSON-LD
for which the media type is
application/ld+json
. However, few, if any, ELM REST services currently support that media type.
One thing I notice is that your code example is manually constructing the requiest URI. This is bad practice. Instead, you should be using OSLC discovery to find the query base URI of the OSLC query capability you want to use. See https://docs.oasis-open-projects.org/oslc-op/core/v3.0/os/discovery.html.In that way, if an OSLC server changes the endpoint URIs in a later release, then clients should not be impacted. If you hard code assumptions about the paths, your OSLC client code will be more fragile and likely to break if such changes happen.
Lastly, 6.0.6.1 went end of service on 2022-10-31 and will no longer be remediated against security vulnerabilities. I highly recommend you upgrade to 7.0.2. Comments I would like to point out that we have gotten another question from this user, about the same or similar topics (OSLC, JSON, JAVA API) and answered pretty much already. The parser error is the same as before. You have also pointed out the issues already in your answer David. Hi Ralph,
But if I am try to use rtc_cm:ownedBy as id it is showing an error like
The Key [rtc_cm:ownedby] was not in the Map.
Cloud you please help on this one.
Thanks. How? You seem to ignore the answers.
As David has already stated in his answer and in https://jazz.net/forum/questions/282584/how-to-return-data-in-json-format-in-eclipse-while-using-http-client-query-method JSON is not a supported media type.
|
![]()
David Honey (1.4k●1●7)
| answered Feb 09, 4:34 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Feb 09, 4:38 a.m.
It looks like
rtc_cm:ownedBy
is not defined as property.
Have you checked the resource shape for resources of that type in that project area to see what properties are defined?
Or looked at the RDF of an example work item from that project area to see how owner is represented?
If I look at work items on jazz.net I do not see a
rtc_cm:ownedBy
propery. Instead, the owner is represented by
dcterms:contributor
as per the OSLC Change Management specification - see https://docs.oasis-open-projects.org/oslc-op/cm/v3.0/os/change-mgt-shapes.html#changerequest.
If I look at the resource shape, I see it contains:
Which tells me that
dcterms:contributor
is the property for owner.
|