Authentication
- Login
- Logout
In order to be able to access any entity an access token needs to generated which serves as session cookies in a regular web language. The token will be needed for every subsequent requests. Except for /api/login enpoint that accept multipart/form-data as the Content type every other endpoints accept application/json as the 'Content Type'.
Token will give the user access only to models which he have access to.
The period which the token needs to be expired is parametrable and you can modify it.
Login (Request access token)

Python request

To retrive an access token these following parameters needs to be set.
- the database name as db
- the connecting username as login
- the user password as password

Logout
To logout of the system the token needs to be destroyed i.e deleted, by doing that the user/application making the request on behalf of the user will have not futher access to Odoo. The token /api/logout listen to both GET and DELETE requests, GET will fetch the token while delete request will deleted the token.
Python request:

CRUD on model.model: Example: sale.order
To get or fetch existing sale order

There is posibilty of applying some record filters in order to get just the specific record.
- limit: This define the total number of record we are expecting
- offset: where the query will start from
- fields: this is the list of field that we wanted to return, this can be leave empty if we wanted to return all the fields.
- domain: domain is like a filter it is always a list of tuples (field, operator, value)
We can perform create, update and delete operation on any records using corresponding HTTP request headers.
- GET: For retriving existing records
- POST: For creating new records
- PATCH: Call an action button on a record
- DELETE: To delete a record
/api{api route}/modelP{model name}/id{optional id for delete request} e.g for sale order Get request to api/sale.order endpoint will return all the sale order in the system.
Get specific element
- Get request

- Response

The reponse with all the fields, but the return fields can specified along side the request, and also, specific records can be specified by sending along the request Odoo domain as json body.

The above will only return 2 maximum records, id, partner and sale order name, that have an ID in the given list [10,11,12,13,14], the offset can be set also.
POST request

PUT request
Put request is meant for updating fields in a record. e.g updating partner name.

In the above request, we send a json body like this {"name":"partner name edited"}, calling the put request updated the res.partrner with id = 15 with new data.
PATCH request
Patch request is meant for calling an action button on a record. example: validating sale order.

In the above request, we send a json body like this {"_method":"action_confirm"} The _method is the action/button name in odoo. This is similar to clicking Confirm Button on sale order with ID 37
DELETE request

We only need to make a delete request to the resource.
Please log in to comment on this module
Report comment
Any abuse of this reporting system will be penalizedIt doesn't work
hello,
this is not working, I installed it locally and on a server, it installed without errors but when trying to login like the example it gives me error 404,
I handled to use rpc instead of it.
Hello,
When I install the module in Odoo 14 CE locally, I get the error 404; with http://localhost:8069/api/login
What could be the problem?
The token /api/logout listen to both GET and DELETE requests, GET will fetch the token while delete request will deleted the token.
get not working for fresh
{"type": "invalid object model", "message": "The model logout is not available in the registry."}
Will it work with Odoo.sh
Hi,
Can we use this with Odoo.sh or only with On-Prim databases?
Hi
I installed this module in Odoo 14 CE, but when I send with curl like the example, I get the error 404; when I send wit postman with "content-type=application/json" I have error 200 from odoo Server, please I need your help
thank you
Hei, my dear collegues! I guess, you also know that no one of you methods except Get, Login and Logout do not work, right? Neither POST nor PUT
Contact me asap, please!
Are you sure this will handle cross origin requests (CORS) because my purpose is to use authentication from react side.
APi documentation et al.
Do you have further documentation for this rest api for odoo. Does it allow CRUD to all objects in Odoo? One thing I wanted to do was update a draft delivery, then validate it and then create a back order delivery if one was required. Do you think your API would allow me to do this? (what api calls would be required)