Community
Enterprise

The odoo Rest API module allow us to connect to database with the help of GET , POST , PUT and DELETE request.

Odoo rest API

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

This module Create and update records from database.

Delete

This module Choose DELETE method to delete records.

Odoo rest API

Are you ready to make your business more organized?
Improve now!

acc_bg

Configuration

  • 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.

Postman collections

  • 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:8018/odoo_connect Replace 'localhost:8018' 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"}.

API Authentication

  • 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:8018/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:8018/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:8018/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:8018/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.

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.

The Odoo REST API module allows users to connect to the Odoo database and perform operations using standard HTTP methods: GET, POST, PUT, and DELETE.

It enables developers to integrate Odoo with other applications and systems, facilitating seamless data exchange and enhancing functionality.

Users can make GET requests to retrieve data, POST requests to create new records, PUT requests to update existing records, and DELETE requests to remove records from the database.

Latest Release 18.0.1.0.0

1st October, 2024
Add
  • Initial Commit

Related Products

Our Services

....