Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

 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?

1

0 votes

Comments

 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
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.

2 votes


Permanent link
For the OSLC QM V2 API in RQM, see https://jazz.net/wiki/bin/view/Main/RqmOslcQmV2Api.

2 votes

Comments
 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? 


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.

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
There are also some videos on YouTube that you may find useful:
http://www.youtube.com/playlist?list=PL8968B48E8DD75B34

1 vote

Comments

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


Permanent link
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

1 vote

Comments

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
 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

0 votes


Permanent link
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.

0 votes

Comments

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
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



















0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938
× 7,495

Question asked: Apr 16 '13, 5:14 a.m.

Question was seen: 19,086 times

Last updated: Oct 12 '17, 4:28 p.m.

Confirmation Cancel Confirm