diff --git a/doc/howtos/backend.rst b/doc/howtos/backend.rst index ddc41dca404..933309ad190 100644 --- a/doc/howtos/backend.rst +++ b/doc/howtos/backend.rst @@ -1709,12 +1709,19 @@ JSON-RPC Library ---------------- The following example is a Python 3 program that interacts with an Odoo server -with the standard Python libraries ``urllib.request`` and ``json``:: +with the standard Python libraries ``urllib.request`` and ``json``. This +example assumes the **Productivity** app (``note``) is installed:: import json import random import urllib.request + HOST = 'localhost' + PORT = 8069 + DB = 'openacademy' + USER = 'admin' + PASS = 'admin' + def json_rpc(url, method, params): data = { "jsonrpc": "2.0", @@ -1725,7 +1732,7 @@ with the standard Python libraries ``urllib.request`` and ``json``:: req = urllib.request.Request(url=url, data=json.dumps(data).encode(), headers={ "Content-Type":"application/json", }) - reply = json.load(urllib.request.urlopen(req)) + reply = json.loads(urllib.request.urlopen(req).read().decode('UTF-8')) if reply.get("error"): raise Exception(reply["error"]) return reply["result"]