I try to create a new data export in python code.
import requests
BASE_URL = "https://kobo.humanitarianresponse.info"
TOKEN = "7c998b69d....." #change with the true token
FORM_ASSET_ID = "aNZSs5ah...." # change with the tru form asset ID
url = '%s/exports/' % (BASE_URL)
headers = {'Authorization': 'token %s' % (TOKEN), "Content-Type" : "application/json"}
myobj = {
"source": "%s/assets/%s/" % (BASE_URL, FORM_ASSET_ID),
"type": "xls",
"fields_from_all_versions": "false",
"lang": "_default",
"hierarchy_in_labels": False,
"group_sep": "/"
}
resp = requests.post(url, data=myobj, headers=headers)
print(resp.status_code, resp.content)
I have a 400 - JSON parse error - No JSON object could be decoded
With the same code, if I create a requests.session(), connect with login/pass and create the sessions cookies. I send this post request through session, it’s ok !
But I don’t want to use login/pass, I want to use token instead !
Do you have any idea ?
thanks