Module Web Services API REST (developer): Difference between revisions

m
no edit summary
Tag: 2017 source edit
mNo edit summary
Tag: 2017 source edit
Line 24: Line 24:
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.
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=
=Installation=
 
To install, open the modules page and activate de "API REST" module.
 
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
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/xxx''' where xxx is name of the API to call.
'''/api/index.php/xxx''' where xxx is name of the API to call.


A list of APIs on your installation can be found via the explorer.
A list of APIs on your installation can be found via the explorer. Click on link to explorer to open the API explorer.


==Apache setup==
==Apache setup==
Line 96: Line 99:


=List of provided services=
=List of provided services=
Only few services are available. Starting to Dolibarr 5.0 version, you can see full list of Dolibarr Web services provided, by calling the explorer here at address:
Only few services are available. You can see full list of Dolibarr Web services provided, by calling the explorer here at address:


'''http://yourdolibarrurl/api/index.php/explorer'''.
'''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 API services.


For example, you can try the explorer on the demo instance at:
On the top right corner, paste the <token> of the user you want to use to call the API and click the "explore" button. Note: The token of each user can be defined on the user record page.
If you prefer, you can first make a first call to the '''login''' API to get the API token key. Then enter API key to get list of all other available API services.


'''https://demo.dolibarr.org/api/index.php/explorer'''


You must first make the first call to the '''login''' api to get the API key.
After clicking on "Explore", you should see all the actions available with this token. If you don't have a lot of actions, it's probably because the according modules are not activated. If you want to see the invoices, you have to activate the invoice module in the configuration of Dolibarr. Same for products, third parties and so on.
Then enter api key to get list of all other available API services.


You can then test directly from this explorer any API. This is the recommended solution to test any Dolibarr API since any API and parameters is documented here. As a result of any test, you will get the answer but also example on how to call the API from command line using '''curl'''.
On this exploration page of the API, you can do quite a lot of tests. Reading datas from Dolibarr and writing, modifying and deleting as well. Warning: Data are really modified in your database.


=Installation=
For example, you can try the explorer on the demo instance at:


To install, open the modules page and activate de API REST module. On the configuration page of the module, there's a link to an explorer. Click on it to open the API explorer.
'''https://demo.dolibarr.org/api/index.php/explorer'''


On the top right corner, paste the <token> of the user you want to use to call the API and click the "explore" button. Note: The token of each user can be defined on the user record page.
You can then test directly from this explorer any API. This is the recommended solution to test any Dolibarr API since any API and parameters is documented here. As a result of any test, you will get the answer but also example on how to call the API from command line using '''curl'''.
 
After clicking on "Explore", you should see all the actions available with this token. If you don't have a lot of actions, it's probably because the according modules are not activated. If you want to see the invoices, you have to activate the invoice module in the configuration of Dolibarr. Same for products, third parties and so on.
 
On this exploration page of the API, you can do quite a lot of tests. Reading datas from Dolibarr and writing, modifying and deleting as well. Warning: Data are really modified in your database.


=Use=
=Use=