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

How to create test case by REST API

Hi,

I successfully get and update the test case by RESTAPI. (I used RQM 3.0.1)
But I'm not sure how to create it.
What I did is
1. Use "GET" to get the xml format of test case. (use "https://my_server/qm/secure/service/com.ibm.rqm.integration.service.IIntegrationService/resources/my_project/testcase/urn:com.ibm.rqm:testcase:123?abbreviate=false")

2. Modify the XML file. Remove the value of <ns4:identifier>, <webId> and <ns5:updated>.


<?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"><projectArea href="https://my_server/qm/resource/itemOid/com.ibm.team.process.ProjectArea/_8YMqYPPLEd-iP_laDqqOyg"/><ns4:identifier></ns4:identifier><webId></webId><ns4:title>Test Studio</ns4:title><ns4:description>Test Studio</ns4:description><creationDate>2010-12-22T03:23:18.291Z</creationDate><ns5:updated></ns5:updated><ns5:state>com.ibm.rqm.planning.common.new</ns5:state><ns4:creator ns3:resource="https://my_server/jts/resource/itemName/com.ibm.team.repository.Contributor/tom">tom</ns4:creator><ns5:owner>unassigned</ns5:owner><locked>false</locked><weight>100</weight><category term="Product" value="product"/><category term="Product Edition" value="A Edition"/><category term="Component / Area" value="A"/><category term="Type" value="GUI"/><category term="Delivery Type" value="Release"/><variables/><testscript href="https://my_server/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/my_project/testscript/urn:com.ibm.rqm:testscript:256"/><template href="https://my_server/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/my_project/template/testcase/com.ibm.rqm.planning.templates.testcase.template_1279286614322"/><com.ibm.rqm.planning.editor.section.testCaseDesign extensionDisplayName="Test Case Design"><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>



3. use "POST" to post this XML body to https://my_server/qm/secure/service/com.ibm.rqm.integration.service.IIntegrationService/resources/my_project/testcase

But I get the error message: The uploaded content does not match the XML schema for testcase.

Could anyone tell what's wrong in my xml file?
Thanks a lot.

0 votes



7 answers

Permanent link
I would suggest removing the remaining read-only properties (e.g. projectArea, creationDate, creator, owner, and locked).

0 votes


Permanent link
I would suggest removing the remaining read-only properties (e.g. projectArea, creationDate, creator, owner, and locked).


Hi Paules,
Thanks for your advice.
But I still meet the same error message.
Now the xml I used is

<?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>Test language selection in XXX Studio</ns4:title><ns4:description>As Ann, I want to select the language to use in XXX Studio so that I can understand on-screen text(RTC - 3450)</ns4:description><ns5:state>com.ibm.rqm.planning.common.new</ns5:state><weight>100</weight><category term="Product" value="XXX Enterprise"/><category term="Product Edition" value="Planner Edition"/><category term="Component / Area" value="Runtime-Client "/><category term="Type" value="Functional"/><category term="Delivery Type" value="Release only"/><variables/><testscript href="https://myserver/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/myproject/testscript/urn:com.ibm.rqm:testscript:256"/><template href="https://myserver/resources/myproject/template/testcase/com.ibm.rqm.planning.templates.testcase.template_1279286614322"/><com.ibm.rqm.planning.editor.section.testCaseDesign extensionDisplayName="Test Case Design"><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>


Do I still miss some element or include some elements which should be removed?
Thank you very much.

0 votes


Permanent link
Hi Bin,
I just tried with your xml in the last post, I can successfully POST the testcase to RQM 301 GA server.
I would suggest removing the remaining read-only properties (e.g. projectArea, creationDate, creator, owner, and locked).


Hi Paules,
Thanks for your advice.
But I still meet the same error message.
Now the xml I used is

<xml><testcase><ns4>Test language selection in * Studio</ns4><ns4>As Ann, I want to select the language to use in * Studio so that I can understand on-screen text(RTC - 3450)</ns4><ns5>com.ibm.rqm.planning.common.new</ns5><weight>100</weight><category><category><category><category><category><variables><testscript><template><com><div></com></testcase>


Do I still miss some element or include some elements which should be removed?
Thank you very much.

0 votes


Permanent link
Hello Hao Wan,

Thank you so much.
I checked my code and there is a mistake that I forgot to add content-type in headers. Now it is OK.

Hi Bin,
I just tried with your xml in the last post, I can successfully POST the testcase to RQM 301 GA server.
I would suggest removing the remaining read-only properties (e.g. projectArea, creationDate, creator, owner, and locked).


Hi Paules,
Thanks for your advice.
But I still meet the same error message.
Now the xml I used is

<xml><testcase><ns4>Test language selection in * Studio</ns4><ns4>As Ann, I want to select the language to use in * Studio so that I can understand on-screen text(RTC - 3450)</ns4><ns5>com.ibm.rqm.planning.common.new</ns5><weight>100</weight><category><category><category><category><category><variables><testscript><template><com><div></com></testcase>


Do I still miss some element or include some elements which should be removed?
Thank you very much.

0 votes

Comments

Hello Bin Wu, am running into similar issue and find this post helpful but you mentioned that after adding content-type in header it worked for you. Wondering how to add the content-type header to a rest api call - can you help share that info? thanks!

Hello Vinod,

It depends what programming language and library do you use. I used Ruby and HTTParty as http client library. I added content type in HTTParty.post method. Eg. in post method, I have :headers=> {'Cookie' => @cookie, 'Content-type' => 'text/xml' }.

Best Regards,


Permanent link
Hi @chocobo8,
glad we solved your problem :)
Hello Hao Wan,

Thank you so much.
I checked my code and there is a mistake that I forgot to add content-type in headers. Now it is OK.

Hi Bin,
I just tried with your xml in the last post, I can successfully POST the testcase to RQM 301 GA server.
I would suggest removing the remaining read-only properties (e.g. projectArea, creationDate, creator, owner, and locked).


Hi Paules,
Thanks for your advice.
But I still meet the same error message.
Now the xml I used is

<xml><testcase><ns4>Test language selection in * Studio</ns4><ns4>As Ann, I want to select the language to use in * Studio so that I can understand on-screen text(RTC - 3450)</ns4><ns5>com.ibm.rqm.planning.common.new</ns5><weight>100</weight><category><category><category><category><category><variables><testscript><template><com><div></com></testcase>


Do I still miss some element or include some elements which should be removed?
Thank you very much.

0 votes


Permanent link

I have another question.  I see here that you can create a test case using the REST APIs.... would I be able to "update" a test case using the REST APIs and the test case identifier (from the existing test case).  Thanks

0 votes


Permanent link
Hi Julie,
I have used the REST API for RQM for a long time
But I guess it is possible, just need to use the HTTP "PUT" method instead of "POST" method

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

Question asked: May 27 '12, 9:44 a.m.

Question was seen: 10,567 times

Last updated: Sep 08 '16, 3:18 a.m.

Confirmation Cancel Confirm