Difference between revisions of "Module Web Services API REST (developer)"
Line 40: | Line 40: | ||
Adding a new REST service is as easy than adding a file called '''api_mymoduleobject.class.php''' into the directory '''htdocs/module/class'''. | Adding a new REST service is as easy than adding a file called '''api_mymoduleobject.class.php''' into the directory '''htdocs/module/class'''. | ||
You take the example into '''htdocs/commande/class/api_orders.class.php''' | You take the example into '''htdocs/commande/class/api_orders.class.php''' | ||
+ | |||
+ | The framework detects automatically the API and it should be visible into the explorer. | ||
+ | |||
+ | Method and parameters are detected according to introspection done into PHP class of the object ('''htdocs/module/class/object.class.php''') using the '''annotations''' found into the class. | ||
+ | For a documentation about annotation: https://github.com/Luracast/Restler/blob/master/ANNOTATIONS.md |
Revision as of 17:37, 9 September 2016
Web services | |
---|---|
Numero/ID of module | 2610 |
User doc. of module | Not applicable |
Developer doc. of module | This page |
Function
When enabling this module, you enable usage of web services provided by Dolibarr server. You can then make REST call of different web services provided by Dolibarr.
Dolibarr REST web services server
Once module webservices REST is activated, Dolibarr become also a server of REST web services. So you can send your own REST request to relative URL /api/index.php
List of provided services
Only few services are available. Starting to Dolibarr 5.0 version, you can see full list of Dolibarr Webservices provided, by calling the explorer here at address:
http://yourdolibarrurl/api/index.php/explorer.
You must first make the first call to the login api to get the api key. Then enter api key to get list of all other available services.
For example, you can try the explorer on the demo instance at:
https://demo.dolibarr.org/api/index.php/explorer
You must first make the first call to the login api to get the api key. Then enter api key to get list of all other available services.
Adding a new service
Adding a new REST service is as easy than adding a file called api_mymoduleobject.class.php into the directory htdocs/module/class. You take the example into htdocs/commande/class/api_orders.class.php
The framework detects automatically the API and it should be visible into the explorer.
Method and parameters are detected according to introspection done into PHP class of the object (htdocs/module/class/object.class.php) using the annotations found into the class. For a documentation about annotation: https://github.com/Luracast/Restler/blob/master/ANNOTATIONS.md