Problème RestAPI pour récupérer données dans BDM

Bonjour,
J’essaie de développer une RestAPI (Bonita 7.2.2) qui retourne en JSON le contenu d’une table de la BDM mais je bute sur des problème de login/session ou de tenantAP :

import org.apache.http.HttpHeaders
import org.bonitasoft.engine.bdm.BusinessObjectDAOFactory
import org.bonitasoft.engine.session.APISession
import org.bonitasoft.web.extension.ResourceProvider
import org.bonitasoft.web.extension.rest.RestApiResponse
import org.bonitasoft.web.extension.rest.RestApiResponseBuilder
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import com.bonitasoft.engine.api.LoginAPI
import org.bonitasoft.engine.platform.LoginException
import com.bonitasoft.web.extension.rest.RestAPIContext
import com.bonitasoft.web.extension.rest.RestApiController

class Index implements RestApiController {

@Override
RestApiResponse doHandle(HttpServletRequest request, RestApiResponseBuilder responseBuilder, RestAPIContext context) {
// To retrieve query parameters use the request.getParameter(…) method.
// Be careful, parameter values are always returned as String values
LOGGER.info("###AccesVehicule### " +
"\n Context - ApiSession.id/username: " + context.getApiSession().getId()+ " - " + context.getApiSession().getUserName());
/*
* Execute business logic here
*/
DateFormat dateTimeJSON = new SimpleDateFormat(“yyyy-MM-dd’T’HH:mm:ss.SSSX”);
Date dateJour = new Date();
String strDateJour = dateTimeJSON.format(dateJour);

	//Get the apiSession from the context
		final LoginAPI loginAPI = TenantAPIAccessor.getLoginAPI();
		final APISession session = context.getApiSession();
	
		//APISession apiSession = loginAPI.login(context.getApiSession().getTenantId(), context.getApiSession().getUserName(), "bpm");
		if (session != null) {
			LOGGER.info("Session: " + session.getId() + " - " + session.getUserName());
		} else {
			LOGGER.info("Session: apiSession est null !");
		}
		
	//Create a DAO factory
	BusinessObjectDAOFactory daoFactory = new BusinessObjectDAOFactory();
	
	//Use the factory to obtain a DAO object
	DemandeAccesVehiculesDAO dao = daoFactory.createDAO(session, DemandeAccesVehiculesDAO.class);
	
	//Use methods on DAO object to access data from the BDM. You can pass input values pre-calculated to the method
	List<AccesVehicule> resultat = new ArrayList<AccesVehicule>();
	
	def List<DemandeAccesVehicules> demandeAccesVehiculess = dao.findByDate(strDateJour, p, c);
	//...
		
	// Send the result as a JSON representation
	// You may use buildPagedResponse if your result is multiple
	return buildResponse(responseBuilder, HttpServletResponse.SC_OK, new JsonBuilder(resultat).toPrettyString())
}

}

J’obtiens des erreurs du type :

2017-04-21 11:29:35.734 +0200 org.bonitasoft.console.common.server.page.RestApiRenderer org.bonitasoft.console.common.server.page.RestApiRenderer renderResponse 
GRAVE: Error when executing rest api extension call to apiExtension|GET|aw/getListeAccesVehicule
groovy.lang.MissingPropertyException: No such property: TenantAPIAccessor for class: fr.universcience.rest.api.Index

Pas mieux en ajoutant :

final APISession session = loginAPI.login(context.getApiSession().getTenantId(), context.getApiSession().getUserName(), “bpm”);`

try using

apiAccessor instead of TenantAPIAccessor

regards
Seán

PS: As this reply offers an answer your question, and if it works, please Mark UP and/or as Resolved.