Absent Member.. Absent Member..
Absent Member..
242 views

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!

0 Likes
0 Replies
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.