Interfacing with Docebo rest API
[Note: This module works only with php5]
What is a REST API
Representational state transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. The terms “representational state transfer” and “REST” were introduced in 2000 in the doctoral dissertation of Roy Fielding, one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification. The terms have since come into widespread use in the networking community.
REST strictly refers to a collection of network architecture principles which outline how resources are defined and addressed. The term is often used in a looser sense to describe any simple interface which transmits domain-specific data over HTTP without an additional messaging layer such as SOAP or session tracking via HTTP cookies. These two meanings can conflict as well as overlap. It is possible to design any large software system in accordance with Fielding’s REST architectural style without using HTTP and without interacting with the World Wide Web. It is also possible to design simple XML+HTTP interfaces which do not conform to REST principles, and instead follow a model of remote procedure call. The difference between the uses of the term “REST” therefore causes some confusion in technical discussions.
Systems which follow Fielding’s REST principles are often referred to as “RESTful”.
How REST API are implemented in Docebo
Docebo doesn't implements a strictly RESTful paradigm but it's more REST-like, since it supports either stateless connection either stateful (it depends on the Docebo configuration). To access Docebo's resources you need to be authenticated on the server, two ways are provided for authentication:
- fixed code (stateless connection): in this case in every request you make to the API, you need to pass an additional parameter with a code pre-defined in Docebo's configuration. User's identity is not known.
- generated token (stateful connection): in this case before making any request to the API, you first need to authenticate on the platform with your Docebo's username and password. Then you will receive a token, which validity is time-limited (time limit depends on Docebo's configuration). After that you need to pass the token as additional parameter in every request to the API. User's identity is known. When token expires, you need to re-authenticate generating a new token.
To access a module you need to use a URL formatted in this way
<root url>/restAPI/<module>/<module function>[/<additional parameters>][.<output format>][!<call method>]
Legend:
- <root url>: the base url of the docebo installation.
- <module>: the module you are referring in your request.
- <module function>: specify the function of the module.
- <additional parameters>: optional parameters in the url (in the form: "/param-1/param-2/.../param-n" ).
- <output format>: optional, the format of the data you will receive as output (at the moment are supported XML and JSON formats). Default: XML.
- <call method>: optional, you may force the request to use a different call method then the real one you are using to send request. It works only if you are using a POST request (you may specify then GET, PUT or DELETE).
Examples
with mod_rewrite enabled and configured : http://<host URL>/restAPI/<module>/<function>
without mod_rewrite enabled and configured : http://<host URL>/doceboCore/rest.php?q=/restAPI/<module>/<function>
See API modules and methods (available on Docebo 3.6)
Reference:
wikipedia: http://en.wikipedia.org/wiki/Representational_State_Transfer