1. What is the issue? Please be detailed.
I am trying to trigger a direct backup on self hosted ODK Central v1.5.3
Using Jupyter-Lab I can connect to the server (so have correctly configured the environment) but I can't get the correct response that will download the backup.
Here is my code:
from pyodk.client import Client
client = Client().open()
r = client.post('/backup', json={"passname": "[my-pass]"})
r.content
I get a memory error (seems to fall over at: "Convert a json object to a bytes")
I tried using r.json()
instead but this doesn't work either.
In both cases the server appears to be working hard, so it has probably triggered a backup, but the issue might be that the data is not being sent in a format that python is expecting?
As an alternative, I had a go at using 'straight' python code as provided in the APIary (which doesn't work as is because urllib2 isn't part of python 3). With some minor changes below, this is what I tried:
from urllib.request import urlopen, Request
values = """
{
"passphrase": "[my-pass]"
}
"""
headers = {
'Content-Type': 'application/json'
}
request = Request('https://[mysite]/v1/backup', data=values, headers=headers)
response_body = urlopen(request).read()
print (response_body)
Unfortunately this fails with:
TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.
I am a little stuck. But it is probably a simple problem that I can't see past! As usual, a little knowledge in the wrong hands is quite dangerous.
Any help gratefully received...