bonita 7.1 , problems with REST api and sessions

1
0
-1

hello guy, i need help please:

I' usign the REST API from bonita 7.1 , and i'm creatig a web application using maven and incorporating bonita REST API.

I'm using this guide:
http://documentation.bonitasoft.com/create-your-first-project-web-rest-a...

so, when i use the function public void loginAs , i can do the login whitout problem (even the function consumeResponse return me status :200 ok).
But then, when i try to use the function private String getUserIdFromSession, first, i build the response with this functions

HttpGet getRequest= new HttpGet(bonitaURI + "/API/system/session/unusedid");
HttpResponse response = httpClient.execute(getRequest, httpContext);

(the httpContext its a variable that contains an specific coockie that i made whit the next funcion:)

public CookieStore getCookieStore ( ){
CookieStore cookieStore = new BasicCookieStore();
BasicClientCookie cookie = new BasicClientCookie(this.USERNAME, this.PASSWORD);
cookie.setDomain("DOMAIN");
cookie.setPath("/");
cookieStore.addCookie(cookie);
return cookieStore;
}

And i asign this value to a variable call cookieStore :

CookieStore cookieStore = new BasicCookieStore();
cookieStore = getCookieStore();
HttpContext **httpContext**;
httpContext = new BasicHttpContext();           
httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);  

then, when i try to call the function extractUserIdFrom, in this part :

String session = EntityUtils.toString(response.getEntity());

the system show me the next message:
response : HTTP/1.1 401 Unauthorized [Server: Apache-Coyote/1.1, Set-Cookie: JSESSIONID=BB6A94AFCCC55253AC8A184861A1D4D0; Path=/bonita/; HttpOnly, Content-Length: 0, Date: Fri, 18 Mar 2016 22:13:10 GMT]

i don't know why i have that answer from the server, because in theory i log in with the function public void loginAs.
So please somebody help my with this case.
Thanks.

p.s. sorry for my bad english.

No answers yet.
Notifications