RegisterLog In to Jazz.net

It's all about the answers!

Ask a question

RQM REST API for Creating Test case


SaiKiran Cheemakurthi (1123) | asked Mar 11 '13, 4:49 p.m.
 I am using following xml and java code for Creating of TC in RQM, but unable to create the TC, Please suggest me if anyone have the solution

<ns4:title>RFT SaiKiran Test Case</ns4:title>
<ns4:description>Hi, All Test Case Creation through RFT, by using RQM Rest API</ns4:description>
<ns5:state>com.ibm.rqm.planning.common.new</ns5:state>
<weight>100</weight>
<category term="AUTO" value="No"/>
<category term="Priority" value="3\-Normal"/>
<category term="Source" value="Mainframe"/>
<category term="System" value="Window"/>
<category term="Subsystem" value="Member"/>
<category term="TC / Usage" value="New"/>
<category term="Test / Cycle" value="Release"/>
<category term="Test / Level" value="System / Integration / Test"/>
<category term="Test / Type" value="SIT"/>
<variables/>
<testscript href="https://MyRQM:9443/jazz/service/com.ibm.rqm.integration.service.IIntegrationService/resources/WAW_Refactoring/testscript/urn:com.ibm.rqm:testscript:256"/>
<com.ibm.rqm.planning.editor.section.testcasedesign extensionDisplayName="RFT_RQM_REST_API">
</com.ibm.rqm.planning.editor.section.testcasedesign>
</testcase>;

Java Code
String username= "AB04206";
String password= "Something"; 
public void testMain(Object[] args) throws IOException 
{
try{
URL url = new URL("https://MyRQM:9443/jazz");
   HttpURLConnection conn =  (HttpURLConnection) url.openConnection();
   
   String userpass = username + ":" + password;
   String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userpass.getBytes());

   conn.setRequestProperty ("Authorization", basicAuth);
   
   conn.setDoInput(true);
   conn.setDoOutput(true);
   conn.setRequestMethod("POST");
   conn.setRequestProperty("Content-Type","application/xml");
   OutputStreamWriter infWebSvcReqWriter = new OutputStreamWriter(conn.getOutputStream());
   String infWebSvcRequestMessage = FileOps.readFile("C:\\CED_TestAutomation\\CED\\cedSource\\cedUtils\\RQMTC_Creation.xml");
       infWebSvcReqWriter.write(infWebSvcRequestMessage);
       infWebSvcReqWriter.flush();
       BufferedReader infWebSvcReplyReader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
       String line;
       String infWebSvcReplyString = "";
       while ((line = infWebSvcReplyReader.readLine()) != null) {
           infWebSvcReplyString = infWebSvcReplyString.concat(line);
           }
       infWebSvcReqWriter.close();
       infWebSvcReplyReader.close();
       conn.disconnect();
       System.out.println(infWebSvcReplyString); 
}catch(Exception e){
System.out.println("here...");
}  
}
Server Response
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=8">
</div> <div>
<link type="text/css" rel="stylesheet" href="/jazz/web/_style/?include=A~&amp;etag=uGpiZTEU_en_US&amp;_proxyURL=%2Fjazz">
<link rel="shortcut icon" href="/jazz/web/net.jazz.ajax/jazz.ico">
<style type="text/css">#net-jazz-ajax-NoScriptMessage { width: 100%; color: #D0D0D0; font-size: 2em; text-align: center; position: absolute; top: 1%; z-index: 999;}</style>
</head>
<body class="tundra"> <noscript>
Javascript is either disabled or not available in your Browser
</noscript>
Loading...
<script type="text/javascript">
djConfig = { isDebug: false, usePlainJson: true, baseUrl: "/jazz/web/dojo/", locale: "en-us", localizationComplete: true };
/*null*/ net = {jazz: {ajax: {}}}; net.jazz.ajax._contextRoot = "/jazz"; net.jazz.ajax._webuiPrefix = "/web/"; </script> <script type="text/javascript" src="/jazz/web/_js/?include=A~&amp;etag=uGpiZTEU_en_US">
</script> <script type="text/javascript"> /* dojo.getObject('jazz.core.loader', true)._loaded=['A'];net.jazz.ajax._rootServices = 'https://vaathmr1149.wellpoint.com:9443/jazz/rootservices';net.jazz.ajax._storageService = 'https://vaathmr1149.wellpoint.com:9443/jazz/storage';net.jazz.ajax._queryService = 'https://vaathmr1149.wellpoint.com:9443/jazz/query';net.jazz.ajax._infoCenterRoot = 'https://vaathmr1149.wellpoint.com:9443/jazz/../clmhelp';net.jazz.ajax._oauthRealmName = 'Jazz';net.jazz.ajax._viewletServiceRoot = 'https://vaathmr1149.wellpoint.com:9443/jazz';net.jazz.ajax._viewletWebUIRoot = 'https://vaathmr1149.wellpoint.com:9443/jazz';net.jazz.ajax._hasLocalRepository = true;net.jazz.ajax._proxyLegacyMode = false;net.jazz.ajax._oauthDomains = ['https://vaathmr1149.wellpoint.com:9443/jazz/'];net.jazz.ajax._friendDomains = ['http://vaathmr1136:12080/cqweb/oslc/repo/WLPRD/','http://vaathmr1136:12080/cqweb/oslc/repo/7.1.1_PROD/','https://va10puvras001.wellpoint.com:9443/jts/','https://va10puvrtc001.wellpoint.com:9443/jazz/','https://va10puvrqm002.wellpoint.com:9443/jazz/','https://va10puvrqm001.wellpoint.com:9443/jazz/']; /* ]]> */ </script> <script type="text/javascript"> /* dojo.addOnLoad( function() { net.jazz.ajax.ui.PlatformUI.createAndRunWorkbench("net.jazz.web.app.authrequired"); }); /* ]]> */ </script>
</body>
</html>

7 answers



link
Brian Fleming (1.4k1425) | answered Mar 11 '13, 5:17 p.m.
Check the URL you are POST-ing to.  According to the RQM API you need to use the singleProjectFeedURL .  To troubleshoot further, I would first get this working using Poster.

Comments
SaiKiran Cheemakurthi commented Mar 11 '13, 5:26 p.m.
Brian,

 thank you so much for recommendation, I will try adding the singleProjectFeedURL.
 Will you please share sample xml for creating TC, if you have one?

Thanks,
 Sai 

1
Brian Fleming commented Mar 11 '13, 8:09 p.m.
Using Poster, perform a GET on an existing test case to get sample xml.  Your testscript URL looks fine.  The singleProjectFeedURL for testcases (what you should set your url variable to) would be: https://MyRQM:9443/jazz/service/com.ibm.rqm.integration.service.IIntegrationService/resources/WAW_Refactoring/testcase

Stephane Leroy commented Jul 08 '13, 10:31 a.m.
JAZZ DEVELOPER
+1 on Brian's answer.

For other examples of URLs (including the one just cited above), you could refer to this post: http://sleroyblog.wordpress.com/2013/04/09/querying-rqm-40-through-oslc-and-rest-api/

link
SaiKiran Cheemakurthi (1123) | answered Mar 11 '13, 5:39 p.m.
 <testscript href="https:/MyRQM:9443/jazz/service&lt;b&gt;/com.ibm.rqm.integration.service.IIntegrationService&lt;/b&gt;/resources/WAW_Refactoring/testscript/urn:com.ibm.rqm:testscript:256"/>

Brain,

 I am using the Integration Service in my XML, please review it

Sai

link
Paul Slauenwhite (6.5k12) | answered Mar 12 '13, 7:07 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
A couple of things:

1) You are not authenticating with the RQM server.  I would suggest using the HTTP client in the RQM URL Utility or RQM Copy Utility source.

2) Your test script URL contains entity references:

https:/MyRQM:9443/jazz/service<b>/com.ibm.rqm.integration.service.IIntegrationService</b>/resources/WAW_Refactoring/testscript/urn:com.ibm.rqm:testscript:256

Comments
SaiKiran Cheemakurthi commented Mar 13 '13, 2:35 p.m.
Paul,

 Now I am able to connect RQM server, I am using the RQM URL Utility, however still unable to create TC or TCER throu program. Always getting error 400 or 500 or 501. Is there any way will you please provide sample XML file for creating TC and TCER. I am unable to follow the instructions API document and creating XML  file

 Any help you provided will be highly helpful for my job

Thanks,
 Sai

Paul Slauenwhite commented Mar 14 '13, 9:31 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Hi Sai,

See https://jazz.net/wiki/bin/view/Main/RqmApi#ScenarioCreateTip for the steps to create valid resource XML.

link
Canberk Akduygu (98221862) | answered Dec 18 '13, 9:41 a.m.
Hello,

I was able to create my test cases via Rest api but I need to obtain the identifier of those test cases so I can link them to the test plan. When I post xml representation of my test case, I only got HTTP 201 nothing more.

Could you help me?

Comments
1
Paul Slauenwhite commented Dec 18 '13, 9:57 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
The Content-Location response header will contain the ID (see https://jazz.net/wiki/bin/view/Main/RqmApi#Create).

Canberk Akduygu commented Dec 19 '13, 2:16 a.m.
 After posting the question I found out my response by myself. I was looking at the wrong side :)

Thank you for quick answer also.

link
Canberk Akduygu (98221862) | answered Jul 24 '14, 8:50 a.m.
Hello,

I am trying to put a value to Categories while creating the Test Plan or Test Case.

I added "<ns4:category value="\"Unit" Test\"="" term="\"Test" Phase\"=""/>" to my TestPlan xml but Categorie is ot set after the execution.

Is there any restriction on some field like Categories,owner,etc?

Comments
Paul Slauenwhite commented Jul 24 '14, 8:53 a.m. | edited Jul 24 '14, 8:54 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Try:

<ns4:category value="Unit Test" term="Test Phase"/>

You may also not have the correct permissions (check the RQM log for relevant log messages).

Canberk Akduygu commented Jul 24 '14, 9:04 a.m.
I gave all the permissions to my user in Test Plan Permissions.
I also cannot edit owner of the test plan via REST api.

I'll try your solution.

Canberk Akduygu commented Jul 24 '14, 9:51 a.m. | edited Jul 24 '14, 9:52 a.m.
I guess jazz.net editor corrupted my xml value. I have <ns4:category value=\"Unit Test\" term=\"Test Phase\"/> this in mycode snippet.


Paul Slauenwhite commented Jul 24 '14, 9:56 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Is there anything in the HTTP response content and/or RQM logs?

link
Canberk Akduygu (98221862) | answered Jul 24 '14, 10:06 a.m.
edited Jul 24 '14, 10:16 a.m.
I sent PUT request to https://wat01ibmclm.int.teb.com.tr:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/TestYonetimi1387280314149%2528Quality%2BManagement%2529/testplan/urn:com.ibm.rqm:testplan

Test Plan is created. I got HTTP 201 message.

Logs are:
2014-07-24 17:01:06,644 [WebContainer : 1 @@ 17:01 Jazz_Report_User /qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/TestYonetimi1387280314149%2528Quality%2BManagement%2529/testplan/urn:com.ibm.rqm:testplan]  WARN com.ibm.rqm.integration.service                     - IntegrationService:handleRequest AQXIN2512W The request URI contains invalid characters. In the request URI, resources/TestYonetimi1387280314149%2528Quality%2BManagement%2529/testplan/urn:com.ibm.rqm:testplan, this segment is invalid: urn:com.ibm.rqm:testplan.
2014-07-24 17:01:06,924 [WebContainer : 1 @@ 17:01 Jazz_Report_User /qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/TestYonetimi1387280314149%2528Quality%2BManagement%2529/testplan/urn:com.ibm.rqm:testplan]  WARN com.ibm.rqm.planning                                - POST with id is improper usage; please do not provide the known id

Comments
Paul Slauenwhite commented Jul 24 '14, 12:54 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
You cannot not use an internal ID on a PUT request (see https://jazz.net/wiki/bin/view/Main/RqmApi#Internal_ID).  In this case, the invalid ID is ignored and a generated ID is used.

Canberk Akduygu commented Jul 24 '14, 3:50 p.m. | edited Jul 24 '14, 3:52 p.m.
"urn:com.ibm.rqm:testplan" is an internal id?
If so which uri do i need to use to make a put request? Also my request creates the test plan in project area. It only dont set the owner and category.

Sorry if i misinterpret what you said.

Canberk Akduygu commented Jul 25 '14, 2:50 a.m.
I found the problem.

My problem was that my tag ids didnt match.

The right usage is:
xmlns:ns2="http://jazz.net/xmlns/alm/qm/v0.1/"
xmlns:ns4="http://purl.org/dc/elements/1.1/"
<ns2:category value="Unit Test" term="Test Phase"/>

The wrong usage is
xmlns:ns2="http://jazz.net/xmlns/alm/qm/v0.1/"
xmlns:ns4="http://purl.org/dc/elements/1.1/"
<ns4:category value="Unit Test" term="Test Phase"/>

I mistakenly put ns4 instead of ns2.

1
Paul Slauenwhite commented Jul 26 '14, 8:09 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Good catch.  Namespace prefixes can sometimes be tricky.  I would have assumed an error/warning would have been logged in the RQM log.

Yes, urn:com.ibm.rqm:testplan is an internal id (except it's missing the web ID).  Note, you cannot use an internal ID in create (POST/PUT) requests.

Canberk Akduygu commented Jul 30 '14, 6:15 a.m.
If I dont use urn:com.ibm.rqm:testplan I cannot create anything.
What's the disadvantages of using it?

Paul Slauenwhite commented Jul 30 '14, 7:05 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
showing 5 of 6 show 1 more comments

link
Canberk Akduygu (98221862) | answered Aug 01 '14, 9:17 a.m.
I have one other question. When we create a test case of test plan via Rest api we get a id with "slug_" prefix. Is there a way to find webId of that test artifact?

Comments
Paul Slauenwhite commented Aug 05 '14, 6:59 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

Your answer


Register or log in to post your answer.