It's all about the answers!

Ask a question

Creating a Work Item in RTC/RQM 4.0 using OSLC REST API Pragmatically in Java


0
1
Rahul Singh Bhadauriya (2821720) | asked Apr 16 '13, 5:14 a.m.
 Hi ,
I have tried to explore the OSLC API in java by following the OSLC Workshop 2012-11-26-OSLC-workshop.pdf
Now I want to create a Work Item using my java code to RTC 4.0 or RQM 4.0 but i didn't found the much documentation and example in the same.
I found some links related to this in Jazz.net but those are outdated.
Can anyone guide/help me regarding this issue?

Comments
Eric Lemes commented Apr 02 '14, 1:02 p.m. | edited Oct 12 '17, 10:05 a.m.

 Hi Rahul,


Did you solve the issue?

I'm having a similar issue consuming the REST API from .NET/C# WebClient. I'm authenticated and able to retrieve work item information, but when creating, I'm receiving an 403 without any more explanation :-(


Regards,

Eric

7 answers



permanent link
Sudarshan Rao (1963) | answered Apr 16 '13, 5:52 a.m.
To create Work Item, you'd have to either use CreationDialog  (provides delegated UI from RTC to create WI)  or CreationFactory (where you'd do a POST to the CreationFactory URI with whatever content needs to go into your WI) service. 
I've not tried the workshop myself, so I don't know if there's any sample in there. To understand how to use CreationDialog or CreationFactory, you can refer to the following article:

Hope that helps.

permanent link
Paul Slauenwhite (8.4k12) | answered Apr 16 '13, 6:52 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
For the OSLC QM V2 API in RQM, see https://jazz.net/wiki/bin/view/Main/RqmOslcQmV2Api.

Comments
Rahul Singh Bhadauriya commented Apr 17 '13, 6:19 a.m. | edited Oct 12 '17, 4:28 p.m.
 Thanks to Paul & Sudarshan ..!!!

Currently i am trying to create Workitem in RTC 4.0.1, While sending a POST request to the JTS server using Creation Factory URL , i am getting exception : HTTP/1.1 403 Forbidden

The java console also shows the following warnings:

Apr 17, 2013 3:04:53 PM org.apache.http.client.protocol.ResponseProcessCookies processCookies
WARNING: Invalid cookie header: "set-cookie: jfs-request-token-921b8e2710b8421491dc2acbd202fa1b="ucmegnBNg42NOrg2lvWgpu3KjUQFnag3m0AsrUUklx8="; Version=1; Max-Age=600; Expires=Wed, 17-Apr-2013 09:44:53 GMT; Path=/cm". Unable to parse expires attribute: Wed
Apr 17, 2013 3:04:53 PM org.apache.http.impl.client.DefaultRequestDirector handleResponse
WARNING: Authentication error: Unable to respond to any of these challenges: {oauth=WWW-Authenticate: OAuth realm=https:<server name>:9443/jts/oauth-authorize

I have added following in the my post request header 
post.addHeader("Accept", "application/xml");
post.addHeader("Content-Type", "application/xml");
post.addHeader("OSLC-Core-Version", "2.0");

I am able to send a GET request successfully to fetch the protected resources like: Creation Factory URI,  Resource Shape URI

Can anybody help me regarding this issue? 



Paul Slauenwhite commented Apr 17 '13, 6:46 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

Your HTTP client is not authenticated with the RTC server.  Try logging into RTC from FireFox and using Poster and/or HttpRequester to make the HTTP request.


Don Yang commented Apr 17 '13, 9:17 p.m.

We have seen 403 error when the below situation applied:

1)the user does not have "create workitem" permission
2) the user does not have right license
3) the user is not the member of the project area
4) after 4.0.0.1, header [X-Jazz-CSRF-Prevent] value as current JSESSIONID(from) is requied: https://jazz.net/forum/questions/98072/x-jazz-csrf-prevent-header-is-required-to-create-a-work-item-via-oslc-on-version-4001


permanent link
Kot T. (1.5k11319) | answered Apr 17 '13, 10:19 a.m.
JAZZ DEVELOPER
There are also some videos on YouTube that you may find useful:
http://www.youtube.com/playlist?list=PL8968B48E8DD75B34

Comments
Rahul Singh Bhadauriya commented Apr 18 '13, 5:38 a.m.

Hi Kot,
Thanks for these useful videos.
It helps me a lot.


permanent link
Stephane Leroy (1.4k149) | answered Apr 17 '13, 11:14 a.m.
JAZZ DEVELOPER
Hi Rahul,

it's a good point you've already experienced the OSLC workshop.
As you've figured out already, it misses an RQM-related section. For the moment (but there are plans to add such subpart to it). In the meanwhile, you've a starting point (code for auth, etc. )

In addition to the RQM wikis (providing extensive information and already pointed out to you by Paul), you could check sample-based "cheat sheets" / "How Tos" provided in this blog:
http://sleroyblog.wordpress.com/2013/04/09/querying-rqm-40-through-oslc-and-rest-api/

Regards,
Stéphane

Comments
Rahul Singh Bhadauriya commented Apr 18 '13, 5:38 a.m.

Hi Stéphane,
The OSLC Workshop really helps me to understand the OSLC REST API.
It would be good to add some samples of the creation factory for RTC and also for RQM in future.
Thanks for the nice workshop material.



permanent link
Mike Jaworski (1.4k6) | answered Apr 24 '13, 10:21 a.m.
JAZZ DEVELOPER
 Rahul,

See if this article offers any help: https://issues.apache.org/jira/browse/HTTPCLIENT-896. It looks like the "Expires" value for your cookie is not in a valid format (for whatever reason) and this article provides some steps in the comments to workaround.

Mike Jaworski

permanent link
Rahul Singh Bhadauriya (2821720) | answered Apr 03 '14, 1:33 a.m.
Hi Eric,
It works fine after adding the header [X-Jazz-CSRF-Prevent] value as current JSESSIONID for me.
reference: https://jazz.net/forum/questions/98072/x-jazz-csrf-prevent-header-is-required-to-create-a-work-item-via-oslc-on-version-4001
i.e  postRequest.addHeader("
X-Jazz-CSRF-Prevent"," AAAACF37530880CEE8034FD5A890453F")
You can also try to make a POST request via REST Client add-on in Firefox.

Comments
Thiruvenkadam Dhanaraj commented Jan 23 '17, 4:44 a.m. | edited Oct 12 '17, 4:28 p.m.

Hi Rahul,

i am trying to create a category in RQM using RESTAPI (Java). i get this error below,

Jan 20, 2017 4:28:13 PM org.apache.http.client.protocol.ResponseProcessCookies processCookies

WARNING: Invalid cookie header: "Set-Cookie: WASReqURL=""; Expires=Thu, 01 Dec 1994 16:00:00 GMT; Path=/; Secure; HttpOnly". Invalid 'expires' attribute: Thu, 01 Dec 1994 16:00:00 GMT

is it because of session id issue ? if so how can i overcome with this problem?

i used IRawRestClientConnection to perform doPost operation.


permanent link
Dinyo Dinev (311235) | answered Oct 28 '15, 4:56 a.m.
In RDNG(6.0.1 M2 in my cases) when you try to create new requirement no matter how REST client(like POSTMAN) or using Eclipse Lyo if you do not specify tititle of the requirement as well as the instanceShape the result is 403 Forbiden. So you can omit the nav:parent, but title and instanceShape are mandatory.
So my request (working ) is :
<rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"xmlns:dc="http://purl.org/dc/terms/"xmlns:public_rm_10="http://www.ibm.com/xmlns/rm/public/1.0/"xmlns:calm="http://jazz.net/xmlns/prod/jazz/calm/1.0/"xmlns:rm="http://www.ibm.com/xmlns/rdm/rdf/"xmlns:acp="http://jazz.net/ns/acp#"xmlns:rm_property="https://grarrc.ibm.com:9443/rm/types/"xmlns:oslc="http://open-services.net/ns/core#"xmlns:nav="http://jazz.net/ns/rm/navigation#"xmlns:oslc_rm="http://open-services.net/ns/rm#" ><rdf:Description rdf:about=""><rdf:type rdf:resource="http://open-services.net/ns/rm#Requirement"/><dc:description rdf:parseType="Literal">OSLC Creation Example 2</dc:description><dc:title rdf:parseType="Literal">OSLC Created Requirement 2</dc:title><dc:contributor rdf:resource="https://10.0.2.79:9443/jts/users/Admin"/><oslc:instanceShape rdf:resource="https://10.0.2.79:9443/rm/types/_opYnsUZsEeWL2aNIq4SA-w"/><nav:parent rdf:resource="https://10.0.2.79:9443/rm/folders/_4du-YEDTEeW98vRabXRPEQ"/></rdf:Description></rdf:RDF>
with header :
Content-Type: application/rdf+xml



















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.