Skip to Content
Menu
This question has been flagged
1 Reply
1539 Views

I have found this code connect odoo with api but from where I can get url, db,username, and password? Can anyone help me from where I can get these credentials?

I have found psql information from odoo shell env. I tried but its showing authentication failed.


Looking for these credentials. Anyone can help to find these information?



import requests

url = "instance url"
db = "your_database"
username = "your_username"
password = "your_password"

headers = {'Content-Type': 'application/json'}
data = {
    'jsonrpc': '2.0',
    'method': 'call',
    'params': {
        'db': db,
        'login': username,
        'password': password
    },
    'id': 1
}

response = requests.post(url, json=data, headers=headers)
session_id = response.cookies.get('session_id')





Avatar
Discard
Best Answer

Hii,

How to Find Odoo API Credentials

This is your Odoo base URL, such as:

http://localhost:8069/web/session/authenticate

Database Name (db)

If using Odoo locally:

  • Open Odoo in browser
  • On the login screen, click the "Manage Databases" link
  • Or go to:
    http://localhost:8069/web/database/manager
  • There you'll see the list of databases

From Odoo shell:

admin@example.com"  # Your Odoo login

password = "your_password"     # Your Odoo password


headers = {'Content-Type': 'application/json'}

data = {

    'jsonrpc': '2.0',

    'method': 'call',

    'params': {

        'db': db,

        'login': username,

        'password': password

    },

    'id': 1

}


response = requests.post(url, json=data, headers=headers)


if response.status_code == 200:

    result = response.json().get("result")

    if result:

        print("Login successful!")

        print("Session ID:", response.cookies.get("session_id"))

    else:

        print("Login failed. Check username/password/db.")

else:

    print("HTTP Error:", response.status_code)

 i hope it is use full 

Avatar
Discard
Related Posts Replies Views Activity
1
Jun 25
495
1
Apr 25
1236
2
Jan 25
1342
1
Jun 24
2118
1
Mar 24
2391