-
-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
404 NotFound #32
Comments
If you want to use import json
import requests
AUTH_URL = 'http://localhost:8069/auth/'
headers = {'Content-type': 'application/json'}
# Remember to configure default db on odoo configuration file(dbfilter = ^db_name$)
# Authentication credentials
data = {
'params': {
'login': '[email protected]',
'password': 'yor_password',
'db': 'your_db_name'
}
}
# Authenticate user
res = requests.post(
AUTH_URL,
data=json.dumps(data),
headers=headers
)
# Get session_id from the response
# We are going to use this as our API key
session_id = json.loads(res.text)['result']['session_id']
# Example 1
# Get users
USERS_URL = 'http://localhost:8069/api/res.users/'
# Pass session_id for auth
# This will take time since it retrives all res.users fields
# You can use query param to fetch specific fields
params = {'session_id': session_id}
res = requests.get(
USERS_URL,
params=params
)
# This will be a very long response since it has many data
print(res.text)
# Example 2
# Get products(assuming you have products in you db)
# Here am using query param to fetch only product id and name(This will be faster)
USERS_URL = 'http://localhost:8069/api/product.product/'
# Pass session_id for auth
params = {'session_id': session_id, 'query': '{id, name}'}
res = requests.get(
USERS_URL,
params=params
)
# This will be small since we've retrieved only id and name
print(res.text) |
@yezyilomo this example not working with odoo version 10
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've tried to GET from
res.users
using postman, and here's my request :GET /api/res.users
Request Body
(I tried using only the Cookie header but it didn't work so I sent the session_id as a parameter as mentioned in the documentation)
Response
The text was updated successfully, but these errors were encountered: