It's all about the answers!

Ask a question

REST get via c# program (testplan /testcase)


max schmiedt (111) | asked Jan 03 '13, 8:46 a.m.

Dear All,

I am writing a little c# program the main steps of it are:

->download a testplan / testcase and save it as an . xml file

I tried to achieve that result by using the REST api of the RQM. Unfortunately my program doesn't return the specified testplan /testcase but the sourcecode of an rational HTML page.

static string HttpGet(string url)

{

//Create web request

HttpWebRequest req = WebRequest.Create(url) as HttpWebRequest;

string result = null;

WebProxy myProxy = new WebProxy("myproxy", 80);

myProxy.BypassProxyOnLocal = true;

req.Proxy = WebProxy.GetDefaultProxy();

//Add authentication to request

req.Credentials = new NetworkCredential("myLogIn", "myPW");

req.Method = "GET";

req.ContentType = "application/xml";

req.Accept = "application/xml";

//Check and accept Certificate

System.Net.ServicePointManager.ServerCertificateValidationCallback +=

delegate(

object sender,

System.Security.Cryptography.X509Certificates.X509Certificate certificate,

System.Security.Cryptography.X509Certificates.X509Chain chain,

System.Net.Security.SslPolicyErrors sslPolicyErrors)

{

return true;

};

get response

using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse)

{

get response stream

StreamReader reader = new StreamReader(resp.GetResponseStream());

result = reader.ReadToEnd();

}

return result;

}

I use the following URL:

The url I use is: "

https://<LOCALHOST>:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/<PROJECTNAME>/testplan/urn:com.ibm.rqm:testplan:<ID>"

I have tried it with the Rational URL Utility and it worked! 

So please help me. I don't understand if somethings missing or wrong.

THANK YOU!

2 answers



permanent link
Ara Masrof (3.2k15) | answered Jan 03 '13, 11:51 a.m.
JAZZ DEVELOPER
Max,
For a quick test, change your request headers to text/xml instead of application/xml and see if it makes any difference.



permanent link
Paul Slauenwhite (8.4k12) | answered Jan 03 '13, 12:33 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
edited Jan 03 '13, 12:39 p.m.
Since you specify the Accept=application/xml header (Resource GET request without an Accept headers returns the 'Loading....' web page. (77982)), it appears you are not authenticating with the JTS server.  See com.ibm.rqm.url.client.RQMUrlUtlyLogin.login(String, String, String) in the RQM URL Utility source (https://jazz.net/wiki/bin/view/Main/RQMURLUtility#Accessing_the_Source - use the same version as your RQM server) for the required HTTP requests to authenticate with the JTS server.

Your answer


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