Hi all,
we have just upgraded integrity to 10.9 from 10.6 and surprisingly java API is not working.
I am using same mksapi.jar to connect to integrity which I used it on 10.6, is this problem?
or I am using wrong minor and major version number for upgraded system@? below is sample code which fails and gives error :
Error :com.mks.api.response.APIConnectionException: Failed to establish a session: Session not authenticated/authorized.
My credentials are correct and using which I can log in through integrity Client GUI.
Code :
public void test_9009()
{
Session session = null;
try
{
String itemID = "1234";
IntegrationPoint ip = IntegrationPointFactory.getInstance().createIntegrationPoint("integritytst.myorg.com", 9009, true, 4, 12);
session = ip.createSession("USERNAME_HERE", "PASSWORD_HERE");
CmdRunner cmdRunner = session.createCmdRunner();
Command cmd = new Command(Command.IM, "viewissue");
cmd.addSelection(itemID);
//printCommand(cmd);
Response response = cmdRunner.execute(cmd);
WorkItemIterator wit = response.getWorkItems();
while (wit.hasNext())
{
System.out.println("****************************WorkItem********************************");
WorkItem wi = wit.next();
Iterator fit = wi.getFields();
while (fit.hasNext())
{
Field field = (Field) fit.next();
System.out.println("\t" + field.getName() + " ---------> " + field.getValueAsString() + " DataType: " + field.getDataType());
}
}
session.release();
} catch (APIException | IOException e)
{
e.printStackTrace();
System.err.println("Error :" + e.getMessage());
}
finally
{
try
{
if (session != null)
{
System.err.println("Closing session............................");
session.release();
}
} catch (IOException | APIException e)
{
System.err.println("unable to close session");
}
}
}
Hello Chinmay Jaiswal,
i am not sure if it is just missing in your example but i think you are missing some steps while establishing your connection to integrity. I think that is why you are getting the Error "Session not authenticated/authorized."
After you have created your cmdRunner you either need to set a default password / user or you need to give that info again for each command.
I usually give a default user and password and then connect to integrity.
You could try the following to establish a connection (your lines 12 - 14):
IntegrationPointFactory ipf = IntegrationPointFactory.getInstance();
IntegrationPoint ip = ipf.createIntegrationPoint("integritytst.myorg.com", 9009, true, 4, 12);
mySession = ip.createSession(userName, password);
cmdRunner = mySession.createCmdRunner();
cmdRunner.setDefaultUsername(userName);
cmdRunner.setDefaultPassword(password);
Command ConnectUser = new Command(Command.IM, "connect");
cmdRunner.execute(ConnectUser);
I'va used that code with 10.7 and 10.8.
Regards,
Dominik
Hi Dominik Thierjung,
Code I mentioned is working well with 10.6 version of server but not with upgraded one(10.9).
Though I have tried with the solution you mentioned and still I am facing same issue.
Thanks,
Hi Chinmay Jaiswal,
i've just noticed you try to set up a secure connection. Whithout that your code works for me (tested with 10.7 api-jar but version set to 4.12).
IntegrationPoint ip = IntegrationPointFactory.getInstance().createIntegrationPoint("integritytst.myorg.com", 9009, true, 4, 12);
Maybe you haven't set up your (new) certificate for your IDE yet?
Regards,
Dominik