RegisterLog In to Jazz.net dW

It's all about the answers!

Ask a question

RQM REST API for Creating Test case


SaiKiran Cheemakurthi (1112) | 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>

4 answers



link
Brian Fleming (9901214) | 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

Stéphane 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 (1112) | 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 (4.6k12) | 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 (9432423) | 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.

Your answer


Register or log in to post your answer.