<div dir="ltr"><span style="font-size:12.8px;font-weight:bold;white-space:nowrap">Hello Juan Hernández,</span><br><div><span style="font-size:12.8px;white-space:nowrap">Thanks you for the help. Now i am able to authenticate using session id.</span></div><div><span style="font-size:12.8px;white-space:nowrap"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 14 March 2016 at 23:00, Juan Hernández <span dir="ltr"><<a href="mailto:jhernand@redhat.com" target="_blank">jhernand@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 02/18/2016 03:22 PM, shailendra saxena wrote:<br>
> Has somebody tried to get API object with the constructor having<br>
> parameters- URL and restapisession- by using java-sdk ?<br>
> Here is the following syntax ?<br>
> Api api =new Api(RestURL,restapisessionID)<br>
><br>
> I have searched a lot but i didn't find anything. Somewhere I read that<br>
> Ovirt has some issue on keeping restapisession. Is it correct ?<br>
><br>
<br>
</div></div>This should work, but the value that you have to pass is the session<br>
cookie plus its value:<br>
<br>
JSESSIONID=asfasdfasdfas<br>
<br>
Also consider using the "ApiBuilder" object, instead of directly the<br>
"Api" constructor, and secure the connection:<br>
<br>
// Get the session id from somewhere:<br>
String sessionId = ...;<br>
<br>
// Create the builder:<br>
ApiBuilder builder = new ApiBuilder()<br>
.url(URL)<br>
.sessionId("JSESSIONID=" + sessionId)<br>
.keyStorePath("ca.jks")<br>
.keyStorePassword("mykeystorepassword")<br>
.debug(DEBUG);<br>
<br>
// The "ca.jks" file above needs to be created from<br>
// the CA certificate of the engine, which is usually<br>
// located in the "/etc/pki/ovirt-engine/ca.pem" file.<br>
// Get that file, and then use a the "keytool" command<br>
// to import it to the "ca.jks" keystore file:<br>
//<br>
// keytool \<br>
// -importcert \<br>
// -keystore ca.jks \<br>
// -file ca.pem \<br>
// -alias ca \<br>
// -storepass mykeystorepassword \<br>
// -noprompt<br>
//<br>
// The resulting "ca.jks" file only contains the CA<br>
// certificate, so its content isn't confidential.<br>
<br>
// Create the API object:<br>
Api api = builder.build();<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta<br>
3ºD, 28016 Madrid, Spain<br>
Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div><div>Thanx & regards,<br></div><br></div>Shailendra Kr. Saxena <br></div>IIIT Allahabad<br></div></div>
</div>