Starting with multiples services on rest server

Hello,
I’m current developing a Dolibarr module for my ERP subject at the high-degree.
The module is working with four objects with some relations between them. I created some examples and they work without problem. I want a rest service to work with a java interface that access to this module objects.
I’m trying to follow this post of the documentation.

In first I create with Dolibarr option “CREATE” a api file called “api_module.class.php”. And It start working a service with the object tab you where. But It doesn’t allow to create another file for the others objects keeping this.
Then I tried to change the name of this file to “api_object.class.php” like the post I shared before explains.
But when doing this after going to api rest explorer and “fetching resource list: http://localhost/dolibarr/api/index.php/explorer/swagger.json; Please wait.” It gives this error “failed to parse JSON/YAML response”.
Then I understood that only one rest service is allowed per module.
But If Dolibarr allows to create a service individual per object. The only solution I’ve in mind is to make only one file with all the services, but I think this will be too complicated. I don’t undestand why i couldn’t use more than once.
I’m using Dolibarr 10.0.0.6.
Anyone know about this?
Thanks in advance!

Hello Alex,

What you are trying to do is not so easy… I haven’t been so far in the API extension and usage yet. First of all, you should look for information on the restler website https://restler3.luracast.com/examples/_006_routing/readme.html
Second, I think your first approach was the correct one. Look at the categories API how it is written and working, I think this is very similar to what you want to do.

Regards,
Marc

Principles of Designing RESTful APIs
Keep it simple. Souce — Internet.
Use nouns and NOT the verbs. A lot of developers make this mistake.
Use of right HTTP methods.
Use Plurals.
Use parameters.
Use proper HTTP codes.
Versioning.
Use Pagination.
I hope this helps!
Regards,
lewis
Developer