Phot from kobotoolbox api

I’m trying to do a masive download of forms through pdf, but I’m stuck with the images, I have access to the data through kobotoolbox api, but I don’t have access to the images, I can’t download the images. I prove my code with github api and it works fine, so, What could I do in this case?

Welcome back to the community, @MichaelOlmosTrujillo! Maybe this post discussed previously should help you solve your issue:

Hi Kal_Lam.
thank you for your reply and time. with respect to the post I have to say that I know this api: https://[kf_url]/api/v2/assets/[asset_uid]/data, in fact, I use this api to download the data of a form, but, when I try to download the images from this api I can’t, I’m not sure if Kobotoolbox has some kind of restriction with respect to the images because I can download text, but not the images. I’m using php and I left attached the code that I use to download the data.


Thank you!

Hi @MichaelOlmosTrujillo, there is no restriction on downloading the images but you have to use the media URLs inside each submission’s _attachments object. Here’s an (abbreviated) example submission’s JSON with the _attachments:

{
  ...
  "_attachments": [
    {
      "download_url": "...",
      ...
    }
  ],
  ...
}
1 Like

Hi Josh, I’m sorry for responding to your answer until this day.
About your answer, yes, I’m using the url from the “attachments” key, but, when I use the url of just one image (as an example) taken from the key “attachments” of a form API I receive a message “Authorization required”. But in my code I use my token and the url of the image. I left attached the image of the code that I use to extract the form image. I’m using PHP. I prove my code with github API and it works fine.

Hi @MichaelOlmosTrujillo, if you paste the URL in your browser or try downloading the image using something like wget do you also see the 404?

TOKEN=<your secret token>
wget --header "Authorization: Token $TOKEN" \
  https://url/to/your/image \
  -O image.png
1 Like

Hi @Josh, If I have initiated my kobotoolbox session and I paste the url image I can see the image and downloading manually, otherwise, without a kobotoolbox session initiated I have a 404. But I want a massive downloading of the images because I’m creating a massive downloading of forms in pdf format for a kobotoolbox session because that is feature that is not implemented in kobo and my organization need it.
The strange part is that my code was working fine until a few weeks ago, I’m not sure what happen.

Hi @MichaelOlmosTrujillo, there’s a chance your issue might be related to the changes made here at the end of 2021:

Do you know if you have full or partial permissions to view data on the form?

1 Like

Hi @Josh. If I have email, password and web token do I need some kind of additional permission? I’m not sure about it because I thought that if I have email, password and web token those are equivalent to a administrator permission, what do you think?

Hi @MichaelOlmosTrujillo, permissions are project specific and are assigned to users by the project owner or someone with “Manage project” permissions. If you are unsure, you can send me the following in a private message so I can take a look:

  • username
  • server (HHI/OCHA)
  • project name
1 Like

Hi @Josh
Thank you, I write you, right now!