Error when importing file to Kobo using API (Create a new form from xls file)

Hello I’m a new Kobo user. I have an issue with creating a new form using xls file using API.
I follow the API used when create new form by uploading xlsform on KoboToolbox, like:

  • Create new asset by POST https://KoboToolbox.url/assets/?format=json with payload {name:"newForm", asset_type: "survey"}. Example response: {uid: "a4Ggs5652sSYnxHuFgoXwy",...}
  • Import file to new form(asset) that created before by POST https://KoboToolbox.url/imports/?format=json with formData {destination: https://KoboToolbox.url/assets/a4Ggs5652sSYnxHuFgoXwy, assetUid: a4Ggs5652sSYnxHuFgoXwy, name: newForm.xls, base64Encoded: dataUrl of newForm.xls}. Example response: {status: "processing", uid: "i9Tbfx9FfD2hLG8JZhoppG", url: "https://KoboToolbox.url/imports/i9Tbfx9FfD2hLG8JZhoppG/?format=json"}
  • Checking the import status by GET https://KoboToolbox.url/imports/i9Tbfx9FfD2hLG8JZhoppG/?format=json

I got the error from the last API. Instead of response status processing/complete I got {"status":"error","uid":"i9Tbfx9FfD2hLG8JZhoppG","messages":{"error_type":"Resolver404","error":{"path":"assets/a4Ggs5652sSYnxHuFgoXwy"}},"date_created":"2019-11-13T12:27:44.683064Z"}. I see the same issue, that issue was fixed and I don’t see any error when create new form from xls file on KoboTollbox, it’s just happen when I using API. Based on reply from that issue, I tried to set the KPI_PREFIX=’/’ on env at docker-compose.yml but still not fixed the issue.
I call the API from another app that have different subdomain with the KoboToolbox server. Also already tried using authentication by Token or just using option withCredential but both of the still show the same error.

Many thanks

I’m sorry with above issue, I just found out that I miss the ‘/’ on the destination parameter(it should be https://KoboToolbox.url/assets/a4Ggs5652sSYnxHuFgoXwy/) and now import API working as expected.

1 Like

Hi @gigu28,

Welcome to the community! Thanks for sharing the solutions with the entire community.

GOOD DAY!