How to make an api request for editing a submitted instance

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.

The challenge is how to to construct working edit link for specific instance in KoBo. I tried to use the following api call:
https://kobo.humanitarianresponse.info/api/v2/assets/akj5HssCp67JRVMV9PqVp6/data/119085042/edit/?return_url=false

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.

Your support would be much appreciated.

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:

https://kobo.humanitarianresponse.info/accounts/login/?next=/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 :slightly_frowning_face:

2 Likes

Thank you so much Dear jnm. That is very helpful and it resolves the issue. Again, Thank you so much.

3 Likes