Closed ladrua closed 3 years ago
What version are using?
Thanks for quick reply. Odoo version 12.0-20190816 Docker image.
Alright I will take a look now
I am able to create and recieve the token fine.
Can you show me the request that lead to the error message, it will help to debug fast.
req = requests.get('{}/api/sale.order/'.format(base_url), headers=headers,
data={'limit': 10, 'domain': []})
print(req.content)
Thanks
It might be something else, I am getting similar issues when using the XML-RPC protocol as well... weird.
Disregard last comment. It is just when using the restful module.
The issue is fixed download the latest update and put the domain inside a string like this
requests.get('{}/api/sale.order/'.format(base_url), headers=headers,data={'limit': 1, 'domain': "[('id', 'in',[2,1])]"})
Without the "" around the domain list it, the domain content will get strip off
Thanks! Can confirm that it now works.
The issue is still present in the 11.0 version. Same issue, the fix didn't worked...
Can help with the error message that you get
Sure
code:
import requests, json
headers = {
'charset':'utf-8',
'content-type': 'application/x-www-form-urlencoded',
}
data = {
'login': 'login',
'password': 'password',
'db': 'db'
}
base_url = 'http://192.168.1.100'
print('{}/api/auth/token'.format(base_url))
req = requests.get('{}/api/auth/token'.format(base_url), data=data, headers=headers)
# 200 - ok
content = json.loads(req.content.decode('utf-8'))
# add the access token to the headers
headers['access-token'] = content.get('access_token')
req = requests.get('{}/api/sale.order/'.format(base_url), headers=headers,data={'limit': 1, 'domain': "[('id','in',[2,1])]"})
print(req)
# 500 - Bad request
server side:
2019-12-11 15:59:24,656 95014 INFO odoo-development-envirment werkzeug: 192.168.1.199 - - [11/Dec/2019 15:59:24] "GET /api/auth/token HTTP/1.1" 200 - 2019-12-11 15:59:24,738 95014 INFO odoo-development-envirment werkzeug: 192.168.1.199 - - [11/Dec/2019 15:59:24] "GET /api/sale.order/ HTTP/1.1" 500 - 2019-12-11 15:59:24,887 95014 ERROR odoo-development-envirment werkzeug: Error on request: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 205, in run_wsgi execute(self.server.app) File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 193, in execute application_iter = app(environ, start_response) File "/usr/lib/python3/dist-packages/odoo/service/wsgi_server.py", line 166, in application return application_unproxied(environ, start_response) File "/usr/lib/python3/dist-packages/odoo/service/wsgi_server.py", line 154, in application_unproxied result = handler(environ, start_response) File "/usr/lib/python3/dist-packages/odoo/http.py", line 1321, in call return self.dispatch(environ, start_response) File "/usr/lib/python3/dist-packages/odoo/http.py", line 1295, in call return self.app(environ, start_wrapped) File "/usr/lib/python3/dist-packages/werkzeug/wsgi.py", line 599, in call return self.app(environ, start_response) File "/usr/lib/python3/dist-packages/odoo/http.py", line 1493, in dispatch result = ir_http._dispatch() File "/usr/lib/python3/dist-packages/odoo/addons/auth_signup/models/ir_http.py", line 19, in _dispatch return super(Http, cls)._dispatch() File "/usr/lib/python3/dist-packages/odoo/addons/web_editor/models/ir_http.py", line 22, in _dispatch return super(IrHttp, cls)._dispatch() File "/usr/lib/python3/dist-packages/odoo/addons/http_routing/models/ir_http.py", line 396, in _dispatch result = super(IrHttp, cls)._dispatch() File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_http.py", line 212, in _dispatch return cls._handle_exception(e) File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_http.py", line 182, in _handle_exception return request._handle_exception(exception) File "/usr/lib/python3/dist-packages/odoo/http.py", line 773, in _handle_exception return super(HttpRequest, self)._handle_exception(exception) File "/usr/lib/python3/dist-packages/odoo/http.py", line 312, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 87, in reraise raise value File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_http.py", line 208, in _dispatch result = request.dispatch() File "/usr/lib/python3/dist-packages/odoo/http.py", line 832, in dispatch r = self._call_function(self.params) File "/usr/lib/python3/dist-packages/odoo/http.py", line 344, in _call_function return checked_call(self.db, *args, *kwargs) File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 97, in wrapper return f(dbname, args, kwargs) File "/usr/lib/python3/dist-packages/odoo/http.py", line 337, in checked_call result = self.endpoint(*a, kw) File "/usr/lib/python3/dist-packages/odoo/http.py", line 939, in call return self.method(*args, *kw) File "/usr/lib/python3/dist-packages/odoo/custom-addons/restful/controllers/main.py", line 46, in wrap return func(self, args, kwargs) File "/usr/lib/python3/dist-packages/odoo/http.py", line 517, in response_wrap response = f(*args, **kw) File "/usr/lib/python3/dist-packages/odoo/custom-addons/restful/controllers/main.py", line 66, in get domain, fields, offset, limit, order = extract_arguments(payload) File "/usr/lib/python3/dist-packages/odoo/custom-addons/restful/common.py", line 54, in extract_arguments payload = json.loads(data) File "/usr/lib/python3.5/json/init.py", line 319, in loads return _default_decoder.decode(s) File "/usr/lib/python3.5/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 2019-12-11 15:59:32,254 94016 INFO odoo-development-envirment odoo.modules.registry: Invalidating all model caches after database signaling.
Can you try the module by cloning branch 12.0 it will work on Odoo v11.0
It worked! Thank you very much from Brazil!
running the example GET in README to get orders result in following error: