Access to images via URL

1. What is the problem? Be very detailed.
I want to access images from ODK central which are submitted as part of the various form. These images should be accessed via URL such as https://central.bdrp.pk/v1/projects/2/forms/CBFS_WOS_DEMO_Formation_Form_v01/submissions/uuid:10a2a193-af41-4475-b866-6f94b5a73q9c84/13_18_56.jpg
However, when I access the URL, its shows the error
{"message":"Could not find the resource you were looking for.","code":404.1}

2. What app or server are you using and on what device and operating system? Include version numbers.
versions:
bc91dbf16c90e00545a55e637d3e9a6bc488f662
4f366fd674d83b7f2f156822e5a8d2ceca563b32 client (v1.2.0)
24d20de20fdf2e03b55e687542fbc0cae889a9ff server (v1.2.0)

3. What you have you tried to fix the problem?
I have used the following mechanism suggested by the valued member. But I am unable to access the images.

4. What steps can we take to reproduce the problem?

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.

Hello @Syed_Muhammad_Qadeer,
sorry to hear you're unable to access your images attached to your submissions. From your post, I can attribute your hard luck to an omission in your URL. You posted

https://central.bdrp.pk/v1/projects/2/forms/CBFS_WOS_DEMO_Formation_Form_v01/submissions/uuid:10a2a193-af41-4475-b866-6f94b5a73q9c84/13_18_56.jpg

but really, what you need should look like

https://central.bdrp.pk/v1/projects/2/forms/CBFS_WOS_DEMO_Formation_Form_v01/submissions/uuid:10a2a193-af41-4475-b866-6f94b5a73q9c84/attachments/13_18_56.jpg

It will be beneficial to note that you can use the format

projectURL+"projects/"+str(projID)+"/forms/"+str(formID)+"/submissions/"+str(instanceID)+".xml"

to get the entire submission. This is beneficial to know the names of the attached multimedia and then use the format

projectURL+"projects/"+str(projID)+"/forms/"+str(formID)+"/submissions/"+str(instanceID)+"/attachments/"+mediaName

to access the individual attachments.

Hope this helps.

2 Likes

Dear @aankrah
This is super helpful and your prompt reply is exactly what I was looking for.
Have a great day.

1 Like

This definitely works! Note that you can also list the expected Submission Attachments by appending /attachments after the instance ID: https://odkcentral.docs.apiary.io/#reference/submissions/attachments/listing-expected-submission-attachments

1 Like

Hi @Matthew_White,

Downloading has been done. Do you have any idea - I want to put the central link directly in the html image source tag?

Kind regards,
Raj

Hi @Raj_Pravat! That's not possible at this time because there's no way for the image tag to authenticate. We know that's a need. You can follow this topic for updates about that feature:

An option that works in some cases is to link to the image. There's a way to do that that will prompt the user to log in if they haven't already: https://docs.getodk.org/central-submissions/#accessing-submission-media-from-external-tools