Availability |
Odoo Online
Odoo.sh
On Premise
|
Lines of code | 269 |
Technical Name |
rest_api_odoo |
License | LGPL-3 |
Website | https://www.cybrosys.com |
Versions | 16.0 17.0 |
Availability |
Odoo Online
Odoo.sh
On Premise
|
Lines of code | 269 |
Technical Name |
rest_api_odoo |
License | LGPL-3 |
Website | https://www.cybrosys.com |
Versions | 16.0 17.0 |
Odoo rest API
The odoo Rest API module allow us to connect to database with the help of GET , POST , PUT and DELETE request.
Key Highlights
Api Key Generation
This module Api key generation using database authentication.
Create Records
Can create records for the models we want to access.
Methods
This module Choose specific methods like GET, POST etc.
Create & Updates
Create and update records from database.
Delete
This module Choose DELETE method to delete records.
- First of all, we have to add a new
parameter in odoo conf.
file.
- server_wide_modules = web, base,
rest_api_odoo
- This will allow us to send request
to
server without
selecting database first.
-
Incase
if you have to
uninstall the module , you have to
remove this parameter.
- Next we can install the
module.
- After installing the Rest api app we
can
see a new api key
field in users.
- Next we have to generate the api-key
for
the current
user.
- You can import the postman
collections
provided in the app
folder for authentication and
interacting with database in
various methods.
- This will allow us to send request to server without selecting database first.
- Incase if you have to uninstall the module , you have to remove this parameter.
- Next we can install the module.
- We have attached Postman
collections through which
you can
authenticate rest api.
- First, extract the zip file.
Then, you will obtain the
JSON-format
file, which you can directly import
into
POSTMAN.
- The url format will be like this -
http://localhost:8017/odoo_connect
Replace 'localhost:8016' with your
localhost port number.
- You have to provide database name,
username and password
through the headers while sending
request.
- If the authentication is successful
, an
api key will be
generated for the current user.
- This key will be used when sending
api
requests to
database.
- The response will be like this -
{"Status": "auth
successful", "User": "Mitchell
Admin",
"api-key":
"66c2ebab-d4dc-42f0-87d0-d1646e887569"}.
- After rest api authentication, we
can
create records in the
rest api app.
- Here we can choose the model, and
also
we can
choose the http methods.
- The api response will be based on
these
records.
Get Records
- You can send GET request to retrieve data from the database.
- The postman collection has been provided with--> app files for sending request from postman.
- You have to provide username, password and api key through the header.
- Model can be passed as argument as the technical name , and also if you want specific record you can provide the id as well,
- The format for GET method will be like this http://localhost:8016/send_request?model=res.partner&Id=10.
- We can specify the fields inside the JSON data, and it will be like this - {"fields": ["name", "email"]}.
- This is the format of api response - {"records": [{"id": 10, "email": "deco.addict82@example.com", "name": "Deco Addict"}]}.
Create Records
- Using POST method , you can create
new records
in the
database.
- Just make sure you enabled POST
method for the
model record
in rest api app , otherwise you will
get 'method
not
allowed' message.
- For creating record you have to
provide the JSON
data along
with the model.
- You can make use of the postman
collection that
we have
added with app files.
- The format for sending POST request
will be like
this - http://localhost:8016/send_request?model=res.partner.
- This is the format for JSON data -
{
"fields" :["name", "phone"] ,
"values": {"name": "abc",
"phone":"55962441552"
} }.
- Make sure the data entered in
correct format
otherwise you
will get 'Invalid JSON data'
message.
- Response will be in this format -
{"New
resource":
[{"id": 51, "name": "abc",
"phone":
"55962441552"}]}.
Update Records
- Updation of records in the database
can be done
with PUT
method.
- You have to provide the model and
also the id or
the record
that you want to update.
- You can use the Postman collection
that we have
provided and , you
will be always have to send request
with your
login
credentials. Otherwise, it will be
showing
access denied.
- The format for sending PUT request
will be like
this - http://localhost:8016/send_request?model=res.partner&Id=46.
- Here too you have to provide the
JSON data
through which the
updates will be done.
- The response format will be like
this - {"Updated
resource": [{"id": 46, "email":
"abc@example.com", "name":
"Toni"}]}.
Delete Records
- Database records can be deleted by
sending
DELETE method
request.
- For the deletion we have to provide
the Model
and the record
id that we want to delete.
- Make sure you have permission to
delete files
for the
selected model in the rest api
record.
- The delete request format will be
like this -
http://localhost:8016/send_request?model=res.partner&Id=46.
- The response after successful
deletion will be
-
{"Resource deleted": [{"id": 46,
"email":
"abc@example.com",
"name": "Toni"}]}.
- We can create records in the rest api app.
- We can send GET request to retrieve data from the database.
- Update of records in the database can be done with PUT method.
- Database records can be deleted by sending DELETE method request.
Initial Commit for Odoo rest API.
Related Products
Our Services
Odoo Customization
Odoo Implementation
Odoo Support
Hire Odoo Developer
Odoo Integration
Odoo Migration
Odoo Consultancy
Odoo Implementation
Odoo Licensing Consultancy
Our Industries
Trading
Easily procure and sell your products
POS
Easy configuration and convivial experience
Education
A platform for educational management
Manufacturing
Plan, track and schedule your operations
E-commerce & Website
Mobile friendly, awe-inspiring product pages
Service Management
Keep track of services and invoice
Restaurant
Run your bar or restaurant methodically
Hotel Management
An all-inclusive hotel management application
Support
Got questions or need help? Get in touch.
Say hi to us on WhatsApp!
Please log in to comment on this module