Uploading XLSForms through kobotoolbox rest api using Python

Hey All,

I am trying to replace xlsforms automatically via following python code but it prints the response code 500 can you guys tell me what’s wrong with my code.

import requests

def upload_to_kobo(xlsform,form_number):

files = {
    'xls_file': (xlsform, open(xlsform, 'rb')),
}
d = r'https://kc.humanitarianresponse.info/api/v1/forms/' + form_number

response = requests.patch(d, files=files, auth=('ihsan_afghanistan', '***'))
print(response)

upload_to_kobo(r’\agysKtkeMyW8FTForzQP9T.xlsx’, ‘420554’)

1 Like

Please don’t post your password on a public forum! I’ve edited it out, but you should change your password ASAP.

1 Like