Pulling data to visualize in a web page

I am working on a community research project. The residents of this community are actively recording data via kobo collect and the web form. I am trying to pull images and coordinates from my database to populate a webpage, so the community can view images collected by their peers and see locations of the different finds. When I enter the url https://kc.kobotoolbox.org/api/v1/data/<form_id>.json. into the browser I get a json file with all the data. However, when I try to load it into my javascript it is not working. I tried setting up the API in Postman but no matter what I do in there I either get an authorization error or detail can’t be found error. I have been scouring the help and everything I could find on APIs in your github pages. I am beginning to question whether this is even possible. What I need to know is 1. Can this be done on the the kobotoolbox.org server? or 2. Do I need to set up my own server? or 3. Can someone please direct me to a document that will explain how to create the url for my javascript to read the json file. Please I am at my wits end.

Hi,
Could you confirm whether the data is publicly shared? You could have been posting this on a browser that remembers your password

Stephane

1 Like

You are right. That the browser is remembering my password. If I use a different browser it will ask for my password. How can I make data public so I can pull it into my javascript. I have created the database with my associate so I have administrative access. If I need to set something up in the database please let me know.

Rather than make the data public, you could code an access token into your website to retrieve the data.

1 Like

Hi @dariengap2021
Based on this trial you have two potential solutions with their pros and cons

  1. Approach one: As clearly articulated by @ks_1
  1. Approach two; By making your data publicly available

Stephane

1 Like

Is there a specific way to insert the access key into the URL. I need help with the syntax that Kobo Toolbox wants me to use. How should I call the API token. I have found multiple suggestions. I can’t seem to find a clear answer on how some use kf.kobotoolbox.org/api/v2/assets others use the kc.kobotoolbox.org/api/vi/data/. The kc.kobotoolbox,org gets the json data in my web browser but. Postman has been useless. No matter what url I use I get either null data

{
“detail”: “Authentication credentials were not provided.”
}
Different APIs have different syntax required to introduce an API

The token goes into the header of the REST API call:

headers = {'Authorization': f'Token {token}'}
2 Likes

Thank you so much.

1 Like

Hello brother
Did this solution solve this problem. I am trying to do the same with authorization token but I am getting CORS error and cannot figure out a way to allow my server to accept requests from my java script api through changing nginx headers.

I do this by fetching the json with PHP curl using Authorisation tokens and curl login
Then I use the data in the page by reading it as an array…

But I cannot find a way to fetch pictures…

I can get my data OK as json on the portal I write for my african project.

Of course I can display and compute text and numbers perfectly well but I cannot find a way to display or download the media files attached.

I get this data in the json:

 ["scan_site_map/filenam_site_map"]=>
  string(8) "Site Map"
 ["scan_site_map/im1_sitemap"]=>
  string(16) "Map-21_44_17.png"

Its not neccessary to download the file immediately, it would be OK to just have a adress, that I can put in a href/img src tags…