Create/Post export request with token

I try to create a new data export in python code.

import requests
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 =, 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 ?

Could you confirm that the following while I consult with our developers:

  1. Is this problem limited to one of your projects or all of them?
  2. Do you have an account on the other server? If so, can you try it on that server and see if it works?


Hi and thank’s for your answer.
Yes, for all of my projects.
I have try on the platform and on my own kobotoolbox server instance (KPI branch master - commit 37709c2e).

I have recreate a test and I have find my problem.
I remove the header “Content-Type” : “application/json” and all is ok !
Thank’s for all.


Hi @jdugh,

Thank you for sharing this to the entire community! The information you shared should benefit the users trying to use the same. Expecting the same in the upcoming days too.

Have a great day!