

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Access Defects via Rest in Alm 12.2
Hello guys,
I have an issue while trying to access the a defect using the sample code from the documentation in a Java client.
It seems like the athentication loses its status and the user is not logged in any more.
Here is the code that was adapted from the documentation:
public static void testReadDefect() throws Exception {
AlmConnector alm = new AlmConnector();
RestConnector conn = RestConnector.getInstance();
conn.init(new HashMap<String, String>(), Constants.HOST2,
Constants.DOMAIN, Constants.PROJECT);
alm.login("admin", "alm123");
System.out.println("The user is in: "+ alm.isAuthenticated());
String defectUrl = conn.buildEntityCollectionUrl("defect");
defectUrl += "/1";
System.out.println (defectUrl);
Map<String, String> requestHeaders = new HashMap<String, String>();
requestHeaders.put("Accept", "application/xml");
Response res = conn.httpGet(defectUrl, null, requestHeaders);
String postedEntityReturnedXml = res.toString();
System.out.println (postedEntityReturnedXml);
alm.logout();
}
If I execute this method I get the following output:
The user is in: null
http://172.16.0.195:8080/qcbin/rest/domains/DEFAULT/projects/ion_test/defects/1
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 401 Authentication failed. Browser based integrations - to login append '?login-form-required=y' to the url you tried to access.</title>
</head>
<body><h2>HTTP ERROR 401</h2>
<p>Problem accessing /qcbin/rest/domains/DEFAULT/projects/ion_test/defects/1. Reason:
<pre> Authentication failed. Browser based integrations - to login append '?login-form-required=y' to the url you tried to access.</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>
</body>
</html>
I have to mention that, The user is in: null, is correct because means that the user is authenticated. But when I try to access the defects stops beeing ok.
In case you need the documentation you need to access:
http://host:8080/qcbin/Help/doc_library/api_refs/REST/webframe.html
Do you know why?
Many thanks!