api: Handle json content-type.

This commit is contained in:
tecnovert
2021-01-28 01:55:42 +02:00
parent 7d0d0687cf
commit 7a9cafb520
5 changed files with 88 additions and 60 deletions

View File

@@ -15,7 +15,7 @@ def callrpc_xmr(rpc_port, auth, method, params=[], rpc_host='127.0.0.1', path='j
'jsonrpc': '2.0'
}
headers = {
'content-type': 'application/json'
'Content-Type': 'application/json'
}
p = requests.post(url, data=json.dumps(request_body), auth=requests.auth.HTTPDigestAuth(auth[0], auth[1]), headers=headers, timeout=timeout)
r = json.loads(p.text)
@@ -38,7 +38,7 @@ def callrpc_xmr_na(rpc_port, method, params=[], rpc_host='127.0.0.1', path='json
'jsonrpc': '2.0'
}
headers = {
'content-type': 'application/json'
'Content-Type': 'application/json'
}
p = requests.post(url, data=json.dumps(request_body), headers=headers, timeout=timeout)
r = json.loads(p.text)
@@ -55,7 +55,7 @@ def callrpc_xmr2(rpc_port, method, params=None, rpc_host='127.0.0.1', timeout=12
try:
url = 'http://{}:{}/{}'.format(rpc_host, rpc_port, method)
headers = {
'content-type': 'application/json'
'Content-Type': 'application/json'
}
if params is None:
p = requests.post(url, headers=headers, timeout=timeout)