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

RQM REST API for Creating Test case

 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

<?xml version="1.0" encoding="UTF-8"?>
<testcase xmlns="http://jazz.net/xmlns/alm/qm/v0.1/" xmlns:ns10="http://jazz.net/xmlns/alm/qm/v0.1/executionworkitem/v0.1" xmlns:ns11="http://jazz.net/xmlns/alm/qm/qmadapter/task/v0.1" xmlns:ns12="http://jazz.net/xmlns/alm/qm/qmadapter/v0.1" xmlns:ns2="http://schema.ibm.com/vega/2008/" xmlns:ns3="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ns4="http://purl.org/dc/elements/1.1/" xmlns:ns5="http://jazz.net/xmlns/alm/v0.1/" xmlns:ns6="http://jazz.net/xmlns/alm/qm/v0.1/testscript/v0.1/" xmlns:ns7="http://jazz.net/xmlns/alm/qm/v0.1/executionresult/v0.1" xmlns:ns8="http://jazz.net/xmlns/alm/qm/v0.1/tsl/v0.1/" xmlns:ns9="http://jazz.net/xmlns/alm/qm/v0.1/catalog/v0.1">
<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">
<div xmlns="http://www.w3.org/1999/xhtml" xmlns:ns10="http://jazz.net/xmlns/alm/qm/v0.1/executionworkitem/v0.1" xmlns:ns11="http://jazz.net/xmlns/alm/qm/qmadapter/task/v0.1" xmlns:ns12="http://jazz.net/xmlns/alm/qm/qmadapter/v0.1" xmlns:ns2="http://schema.ibm.com/vega/2008/" xmlns:ns3="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ns4="http://purl.org/dc/elements/1.1/" xmlns:ns5="http://jazz.net/xmlns/alm/v0.1/" xmlns:ns6="http://jazz.net/xmlns/alm/qm/v0.1/testscript/v0.1/" xmlns:ns7="http://jazz.net/xmlns/alm/qm/v0.1/executionresult/v0.1" xmlns:ns8="http://jazz.net/xmlns/alm/qm/v0.1/tsl/v0.1/" xmlns:ns9="http://jazz.net/xmlns/alm/qm/v0.1/catalog/v0.1"/>
</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
<!DOCTYPE html>
<html >
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=8">
<title>
</title>
<link type="text/css" rel="stylesheet" href="/jazz/web/_style/?include=A~&etag=uGpiZTEU_en_US&_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>
<div id="net-jazz-ajax-NoScriptMessage">Javascript is either disabled or not available in your Browser</div>
</noscript>
<div id="net-jazz-ajax-InitialLoadMessage">Loading...</div>
<div id="net-jazz-ajax-WorkbenchRoot"></div>
<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~&etag=uGpiZTEU_en_US">
</script> <script type="text/javascript"> /* <![CDATA[ */ 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"> /* <![CDATA[ */ dojo.addOnLoad( function() { net.jazz.ajax.ui.PlatformUI.createAndRunWorkbench("net.jazz.web.app.authrequired"); }); /* ]]> */ </script>
</body>
</html>

1 vote



7 answers

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

0 votes

Comments

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 

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

1 vote

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


Permanent link
 <testscript href="https:/MyRQM:9443/jazz/service/com.ibm.rqm.integration.service.IIntegrationService/resources/WAW_Refactoring/testscript/urn:com.ibm.rqm:testscript:256"/>

Brain,

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

Sai

0 votes


Permanent link
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&lt;b&gt;/com.ibm.rqm.integration.service.IIntegrationService&lt;/b&gt;/resources/WAW_Refactoring/testscript/urn:com.ibm.rqm:testscript:256

0 votes

Comments

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

Hi Sai,

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


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

0 votes

Comments

The Content-Location response header will contain the ID (see https://jazz.net/wiki/bin/view/Main/RqmApi#Create).

1 vote

 After posting the question I found out my response by myself. I was looking at the wrong side :)


Thank you for quick answer also.


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

0 votes

Comments

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

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.

I guess jazz.net editor corrupted my xml value. I have <ns4:category value=\"Unit Test\" term=\"Test Phase\"/> this in mycode snippet.

Is there anything in the HTTP response content and/or RQM logs?


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

0 votes

Comments

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.

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

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.

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.

1 vote

If I dont use urn:com.ibm.rqm:testplan I cannot create anything.
What's the disadvantages of using it?

showing 5 of 6 show 1 more comments

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

0 votes

Comments

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

Question asked: Mar 11 '13, 4:49 p.m.

Question was seen: 14,741 times

Last updated: Aug 05 '14, 6:59 p.m.

Confirmation Cancel Confirm