Skip to Content
Menu
This question has been flagged
6 Replies
10712 Views

I'm trying to send JSON-RPC request using plain http POST request.
But I have trouble defining additional request option like limit or fields.

Here is my request body:
https://pastebin.com/1bkHb0Z3

And this is the response:

https://pastebin.com/ikV3X0Zy

When I'm sending a request without this additional contraint {"fields": ["id", "name", "email"]} I receive all the fields and I don't need them. 
Basically when I put anthing, like a limit or fields contraint, it returns only the record id and nothing else. Why? How to fix it?


Avatar
Discard
Best Answer

You need to pass the args in the same list In your request, in the pastern you are passing separately the domain and the fields, you should pass them in the same list: 


take a look at the Odoo cookbook example \https://books.google.com.mx/books?id=4NRJDwAAQBAJ&pg=PA390&lpg=PA390&dq=jsonrpc+odoo+search_read&source=bl&ots=oj5ckTbCIP&sig=ACfU3U1rTOasUKZ2wETpvaHaZ3Z8prgYhQ&hl=en&sa=X&ved=2ahUKEwiv4IWsisHnAhUXFTQIHU0NCs0Q6AEwCXoECAwQAQ#v=onepage&q=jsonrpc odoo search_read&f=false

EDIT: 

This is the right way to do what was initally asked here https://pastebin.com/MTeE4786



Avatar
Discard
Author

How exactly?

I tried this:

https://pastebin.com/bS46mimc

And I'm getting an error:

"need more than 1 value to unpack"

hello, i managed to make it work like this:

https://pastebin.com/MTeE4786

If it works, do not forget to mark the answer as correct.

regards

Author

Thanks, that worked. But is there any documentation about order of the parameters?

How would I know (except testing it myself) that there is method, followed by record rules, then fields, then offset, then limit? Like this:

"search_read",[["id", "=", "177"]],["id", "name", "email"],0,3

In a typical xmlrpc request parametrs like limit or fields are inside object with a assigned names, so the order does not really matters.

The only way to understand the order of the parameters is by reading the code of the api, you can reffer to Odoo's official documentation but that is not always the best way to go, for example for your request you need to find the code of the search_read method.

that can be found in odoo/odoo/api.py here is the diretct link to the method https://github.com/odoo/odoo/blob/13.0/odoo/models.py#L4799

All of Odoo's ORM core methods are in that file and they are very well documented.

additionally you can take a look at this Quora explanation about positional arguments:

https://www.quora.com/What-is-a-positional-argument-in-Python-programming

hope it helps.

Best Answer

Hello Anj Just now I came across your Question I faced a Similar issue but I resolved it Here I paste my JSON request Body.

Creating Records:

{
    "jsonrpc""2.0",
    "method""call",
    "params": {
        "service""object",
        "method""execute",
        "args": [
            "<DB>",
            <UID>,
            "<password>",
            "library.book",
            "search_read",
            [["name""ilike""JSON"]],
            {"fields": ["name""date_release"]}
        ]
    }
}
its Work if it useful for you kindly mark this also as an answer
Avatar
Discard
Related Posts Replies Views Activity
0
Jun 22
1846
1
Sep 20
5949
1
Mar 20
3074
5
Jan 20
8742
0
Mar 17
3892