# How to use more files in Rest API extension?

**URL:** <https://community.ofelia.com/t/how-to-use-more-files-in-rest-api-extension/10691>\
**Category:** Q&A\
**Created:** [12 March 2021 06:42 UTC](https://community.ofelia.com/t/how-to-use-more-files-in-rest-api-extension/10691 "2021-03-12T06:42:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kurucsai.zoltan1988](https://avatars.discourse-cdn.com/v4/letter/k/edb3f5/32.png) [@kurucsai.zoltan1988](https://community.ofelia.com/u/kurucsai.zoltan1988)\
**Post date:** [12 March 2021 06:42 UTC](https://community.ofelia.com/t/how-to-use-more-files-in-rest-api-extension/10691/1 "2021-03-12T06:42:56Z")

</div>

Hello,

I made a Rest API extension based on this documentation (the last part:&nbsp;Returning the whole object with an API link load in the lazy fields)

https://documentation.bonitasoft.com/bonita/7.11/bdm-in-rest-api

My properties file looks like this:

RateBDMQuery.pathTemplate=RateBDMQuery  
displayName=Rate Query  
name=custompage\_RateBDMQuery  
description=Lekéréseket végez  
RateBDMQuery.method=GET  
RateBDMQuery.permissions=task\_visualization  
RateBDMQuery.classFileName=RateBDMQuery.groovy  
contentType=apiExtension  
apiExtensions=RateBDMQuery

If i use the same exact order: SERIALIZER, MAPPER, INDEX

Then my Rest API doesnt work (although i renamed my class it isnt INDEX). The portal loads the first class it sees and if it isnt the Rest&nbsp;API controller, then it doesnt work. If i switch the order and put the controller class at the start, it works.&nbsp;

I also tried to pack the 3 classes in 3 files, but the extension cant find the other classes, can i define them as dependencies in this properties files?

I want to make more reusable classes, and use them in a Rest API extension, but until now i didnt found a way to do that, i needed to put the class in the same file as the index. So if i want to use it in a another extension i need to copy the code, and if i need to change it i need to change it in multiple places. This is not so convinient, thats the reason why im asking, if there is a way to include other class files in the extension?&nbsp;

---

<div class="post-metadata">

**Author:** ![romain.bioteau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/romain.bioteau/32/720_2.png) [@romain.bioteau](https://community.ofelia.com/u/romain.bioteau)\
**Post date:** [15 March 2021 10:25 UTC](https://community.ofelia.com/t/how-to-use-more-files-in-rest-api-extension/10691/2 "2021-03-15T10:25:18Z")

</div>

Hi,

Here is [an example](https://github.com/Bonitasoft-Community/multi-endpoint-api-example) of the REST API extension project using multiple endpoints.

In term of reusability, the project above is a common maven project so you can create all the classes and use all the maven dependencies you need (as long as they are not conflicting with the runtime).

I hope it will help you solving your issue.

Romain

---

<div class="post-metadata">

**Author:** ![kurucsai.zoltan1988](https://avatars.discourse-cdn.com/v4/letter/k/edb3f5/32.png) [@kurucsai.zoltan1988](https://community.ofelia.com/u/kurucsai.zoltan1988)\
**Post date:** [16 March 2021 14:51 UTC](https://community.ofelia.com/t/how-to-use-more-files-in-rest-api-extension/10691/3 "2021-03-16T14:51:19Z")

</div>

Hi,

Thank you, i will try using the extension, does this work with 7.11.4 version of Bonita? I remember a youtube video explaining how to use maven etc with 2021.1 version of Bonita, but is is possible to use this example for the older 7.11.4 version?

Another question if i want to create a RestAPI extension similar to the Bonita BDM API

./API/bdm/businessData/ **{{businessDataType}}**?q= **{{queryName}}** &p=0&c=10&f= **{{filter}}**

Is there a good example how to extract the f parameter? I know i can user request.getParameters("f"), and then i get an array containing the name/value pairs with = between them, and that i can split and evaluate. But i bet there is a more beautiful way of doing this :)

Regards&nbsp;

Zoltan

---

<div class="post-metadata">

**Author:** ![romain.bioteau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/romain.bioteau/32/720_2.png) [@romain.bioteau](https://community.ofelia.com/u/romain.bioteau)\
**Post date:** [16 March 2021 15:56 UTC](https://community.ofelia.com/t/how-to-use-more-files-in-rest-api-extension/10691/4 "2021-03-16T15:56:00Z")

</div>

The example I’ve provide is compliant with 7.11.4 😉 (note that it is also compatible with 2021.1, it is just that in 2021.1 the archetype use a maven assembly that is not backward compatible)

I’d recommend to develop more specific API for you BDM instead of trying to reimplement ours. Ours where design this way in order to be generic. You could however for your project directly design API like this for your apps:

`../API/extension/bdm/MyBusinessObject?id={{persistenceId}}` or  
`../API/extension/bdm/MyBusinessObject/find?p=0&c=10` or  
`../API/extension/bdm/MyBusinessObject/customQuery?p=0&c=10&customParam=a`… and so on

HTH  
Romain

---

<div class="post-metadata">

**Author:** ![kurucsai.zoltan1988](https://avatars.discourse-cdn.com/v4/letter/k/edb3f5/32.png) [@kurucsai.zoltan1988](https://community.ofelia.com/u/kurucsai.zoltan1988)\
**Post date:** [17 March 2021 07:04 UTC](https://community.ofelia.com/t/how-to-use-more-files-in-rest-api-extension/10691/5 "2021-03-17T07:04:35Z")

</div>

Hi,

Thank you for the advice :)

I have 1 problem with the example, im using spring tool suit (it is basicly&nbsp;ecplise), and have this error in the projects pom.xml:

Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (execution: default-compile, phase: compile)&nbsp;&nbsp; &nbsp;pom.xml&nbsp;&nbsp; &nbsp;/multi-endpoint-api-example-main&nbsp;&nbsp; &nbsp;line 122&nbsp;&nbsp; &nbsp;Maven Project Build Lifecycle Mapping Problem  
&nbsp;

I still searching for a solution, im just curious, maybe you know the answer to this, someone mentioned to put&nbsp;\<pluginManagement\> tag before plugins (and of course the close tag after plugins). But this didnt work.

&nbsp;

---

<div class="post-metadata">

**Author:** ![romain.bioteau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/romain.bioteau/32/720_2.png) [@romain.bioteau](https://community.ofelia.com/u/romain.bioteau)\
**Post date:** [17 March 2021 08:53 UTC](https://community.ofelia.com/t/how-to-use-more-files-in-rest-api-extension/10691/6 "2021-03-17T08:53:00Z")

</div>

You need to install the eclipse m2e connectors. [Eclipse prompt a wizard](https://ibb.co/bvfknNs) to install them when you import the project as a maven project in your worksapce.

You will also need to install groovy-eclipse from the eclipse marketplace. Becarefull as groovy eclipse just released a new version that dropped the support for groovy 2.4.x (which is the version currently used in bonita). So you should installed the previous version (3.9.x) using their update site.

HTH  
Romain
