Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Web API login works, but requesting data doesn't

By
Vincent van Steenes
on 6/23/14, 8:46 AM 1,093 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.

0

Ludo - Neobis

--Ludo - Neobis--
2387
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--

Developer

Ludo - Neobis
On 6/23/14, 9:15 AM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/23/14, 8:46 AM
Seen: 1093 times
Last updated: 3/16/15, 8:10 AM