Skip to Content
Menu
This question has been flagged
3 Replies
12141 Views

I'm having some trouble requesting data through the web API. What works is logging in. I log in by requesting /web/session/authenticate and I get a session id in return. With this session id I would like to request some data.


I try requesting the data through /web/dataset/search_read given the following parameters:

[content] => {"jsonrpc":"2.0","method":"call","id":"<ID_GOES_HERE>","params":{"model":"product.product","domain":[],"fields":["price"],"session_id":"<SESSION_ID_GOES_HERE>"}}
[header] => Content-Type: application/json
Connection: Close
Cookie: session_id=<SESSION_ID_GOES_HERE>; Expires=Sun, 21-Sep-2014 11:59:02 GMT; Max-Age=7776000; Path=/
[method] => POST
[timeout] => 5

In the return headers of the search request is a HTTP/1.1 403 FORBIDDEN.

Ofcourse, the session id I send with the request is the same as I get in return from the server when I log in. Also, when i request /web/session/get_session_info, I get this in return with the correct session id:

{"jsonrpc": "2.0", "id": "<ID_GOES_HERE>", "result": {"username": "<USERNAME_GOES_HERE>", "user_context": {}, "db": "<DB_GOES_HERE>", "uid": false, "session_id": "<SESSION_ID_GOES_HERE>"}}

I notice that user_context is empty and the uid is false. Can anyone tell me if I'm doing something wrong? I'm using the online version of Odoo.

Avatar
Discard
Best Answer

I had the same issue,

add the session id to the header of request not the body,

x-openerp-session-id:<your session id>

 

Avatar
Discard
Best Answer

I have same problem with odoo 12 . my app is work fine by odoo 10 and odoo 11.

did you find any solution?

thanks

Avatar
Discard
Best Answer

I have never used the web API this way so I don't know anything about that, but what I can tell you is that almost every function of the ORM in Odoo uses the UID to determine if a user is able to perform said function. 

Are you able to manually provide a uid? You can use the admin's uid for testing purposes (this is usually id 1). 

Also, check if the call for search_read is already implemented. I have tried it recently and found it not to be working (although it was in the docs). Try a simple search first and see if you get any results.. 

Avatar
Discard
Related Posts Replies Views Activity
2
Dec 19
6227
0
Oct 20
3061
2
Jul 18
7476
0
Nov 24
52
0
Oct 24
103