Hello Kobo team and community. I hope you are doing well and having good health.
I am creating a web map on ArcGIS Online making use of the submitted data of a specific form in KoboToolbox. I used power query in Excel for connecting to the form. Then, I published the data as hosted feature layer to be used in ArcGIS Web Map. I also wrote a python script to update the layer when the data is updates on Kobo. When the user click on a point on the map, Pop up will appear that contains few information about that point along with a link to edit its data through koboToolbox. The steps would be as follows:
Step01: The user click the point on the map
Step02: Popup window appears showing the edit link for making API requests to edit the data of that point (instance) in KoboToolbox.
Step03: The user click the edit link , new tab in the browser opens and the login page of kobo toolbox open asking the user for their credentials. The user fill the credentials and redirected to the instance to be edited.
But it didn’t work. I guessed the problem is in the authentication. I don’t have enough information on how to construct the api call with authentication.
I could be overlooking something, but I don’t think we have a great way to do this. A quick and dirty way to prompt for credentials and then redirect to another KoBo endpoint is to use https://kobo.humanitarianresponse.info/accounts/login/?next=[destination], where [destination] in your case would be /api/v2/assets/akj5HssCp67JRVMV9PqVp6/data/119085042/edit/?return_url=false:
This does “work” in the sense that it prompts for a username/password and then, if you have permission, shows you the one-time-use Enketo link for editing that submission in a JSON response. In Firefox, it’s not so bad, because it has a built-in, fancy JSON renderer that turns URLs into hyperlinks. In other browsers, your users would probably have to copy and paste a URL into the address bar
I have the same issue, and I think I’m close to solving it but I’m not figuring out what this number (119085042) in the url is.
I’ve tried using instance id and uuid but nothing worked.
@nartabaza, could you provide some more detail, please? Do you get an error code like 404, 403, etc.? Are you logged in as the owner of the project, or as someone with particular assigned permissions?
We don’t yet have enough information to help you or identify a problem with the software.
@stephanealoo, if we can’t figure out anything after the next message, we’ll likely need to take this private and find out which account and project are specifically affected. Thanks.
I go to https://kobo.humanitarianresponse.info/api/v2/assets/
find my project, and copy its uid
then I copy an instance id (from the _id field) and construct the link you’d suggested above:
Hi @nartabaza, it looks like the recent update has caused this issue. We’ve updated the edit URL from /api/v2/assets/[uid]/data/[_id]/edit/ to /api/v2/assets/[uid]/data/[_id]/enketo/edit/ (so that we can also have /enketo/view) but it was meant to still be compatible with the previous URL. In the meantime, please try amending your URL and see if that solves your issue — it worked on my end.
I made changes to my question types last month so I have to edit the old submissions to fit the new format (from a string question to integer question with another string question for remarks) .
I have problems with the table ui not loading sometimes/slow . Is there a documentation on how to do this via API?
The R httr call for this is similar to the download request?
My idea is to download the whole csv and make the necessary corrections and loop for each changed row.
Even a list of general steps is helpful.
PS: This is also better because I will have the copy of edited and unedited files in my computer. Easier to track changes rather than editing in the UI.
I’m trying again with a recent project but still not working.
I’m using this url: https://kobo.humanitarianresponse.info/api/v2/assets/azq8z4LQhekcmWta8RTyra/data/313064979/enketo/edit/?return_url=false
and getting this in Chrome: {"url":"https://ee.humanitarianresponse.info/edit/EKcAVZkP?instance_id=f83e5a8c-e4e6-44bb-99c7-9524ffd77d45&return_url=false"}
refreshing the page after that, gives a different message: {"detail":"Enketo error: Not allowed. Record is already being edited"}
any suggestions?
Update:
Copying the url that I got from the browser worked!
I’d still appreciate it if there was a way to directly redirect to it.
Hi @nartabaza, if you refresh the page, i.e. make another request for editing, in less than 30 seconds after the previous request, it will show that error. It is a crude way to prevent multiple simultaneous edits to a submission. Regarding redirects, the Kobo UI makes this same API request and then handles the redirect — so you will have to do similarly if that’s the behavior you’re wanting.
but how do I handle the redirect if the link is constructed in powerBI and the user is coming from a published report? is there something I can add to the url?
Hi @nartabaza currently the frontend handles the redirection, but I have created an issue here to account for your use case and similar requests previously: