Hi @locust, that is concerning. Would you mind please sharing the following with me in a private message so that I can take a look:
- Server (OCHA/HHI)
- Username
- Project name
In the meantime, you can do the following to meet your original need of pulling data based on specific criteria. Let’s assume you have a question called country
and you also want to limit the _submission_time
property to submissions after a certain date.
In a terminal (or with a REST client), you can do the following:
curl https://KF_URL/api/v2/assets/ASSET_UID/data/?query={"country":"Sudan", "_submission_time":{"$gt":"2021-03-02T18:34:12.498-08:00"}}&format=json \
-H "Authorization: Token TOKEN"
This will filter all records with country
equal to “Sudan” with a _submission_time
after “2021-03-02T18:34:12.498-08:00”. You can direct the output to a file and consume the data from there.
If you are familiar with Python, you could do something like the following to get it back into an XLS file:
import requests
import pandas as pd
TOKEN = 'your-token'
KF_URL = 'kf.kobotoolbox.org' #or 'kobo.humanitarianresponse.info'
ASSET_UID = 'your-asset-uid'
QUERY = '{"country":"Sudan", "_submission_time":{"$gt":"2021-03-02T18:34:12.498-08:00"}}'
URL = f'https://{KF_URL}/api/v2/assets/{ASSET_UID}/data/?query={QUERY}&format=json'
headers = {"Authorization": f'Token {TOKEN}'}
response = requests.get(URL, headers=headers)
data = response.json()
df = pd.DataFrame(data['results'])
# export to xls
df.to_excel('my-data.xlsx')
Hope that helps.