I have a Python script that can log into Odoo using RPC calls to the jsonrpc url. The scripts works if I run it on the Odoo server and point it directly to Odoo.
login_parms = {
"id": conversation_id,
"jsonrpc": "2.0",
"method": "call",
"params": {
"args": [database, username, password],
"method": "login", "service": "common"}}
response = requests.get(
url,
json=login_parms,
headers={'Content-Type': 'application/json', })
However, when I try and run the script remotely, I receive a 400:
Function declared as capable of handling request of type 'json' but called with a request of type 'http'
I'm using nginx as a proxy and my best guess is it is not correctly sending 'json' as the mime type. I've tried adding the following location block to my server block:
location /jsonrpc {
proxy_pass http://127.0.0.1:8069/jsonrpc;
proxy_redirect off;
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 300M;
default_type application/json;
}
But I am receiving the same 400 error.