Sending files to other systems via Rest API

I am new to this system and I would like to know how is the correct way to send files and photos through the APIs for another system.

Thank you.

Hi @viperboys are you referring to the REST Services or just accessing media through the kobo API endpoints?

1 Like

Hi @Josh Through REST service.

Hi @viperboys, you are only able to send JSON or XML through the REST Service. You can however pull the media files using the API endpoints.

1 Like

Hi @Josh
My idea is to send the KoboToolBox data to a website made in WordPress. I tried it and it only worked for me sending basic fields. When I submitted a photo I got an error. So I wanted to know if KoboToolBox could do it. If the answer is yes then I have to check on the WordPress side.

Hi @viperboys, I’m not sure how WordPress will handle things, but from the kobo side, you can see the media attachment URLs by navigating to the /data API V2 endpoint, in the _attachments array for each submission.

https://KF_URL/api/v2/assets/ASSET_UID/data.json

Hi @Josh
This is not very clear to me since I am new. Is there anything you can read to learn more about it?

Hi @viperboys, you can get started here on the support page for the API:

https://support.kobotoolbox.org/api.html

And look at the API docs for V2 here:

https://kf.kobotoolbox.org/api/v2/assets/

1 Like

As an example, if I navigate to this URL, this is what I will find for a simple form with a single media upload question:

https://kf.kobotoolbox.org/api/v2/assets/apKQ7eoSRB2Bk8wD2uMjkx/data.json

{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "_id": 94571949,
      "_notes": [],
      "_validation_status": {},
      "_uuid": "44113165-acdf-448d-b984-f5952d10974b",
      "_tags": [],
      "submit_an_image": "image-8_58_16.jpg",
      "_submitted_by": null,
      "_xform_id_string": "apKQ7eoSRB2Bk8wD2uMjkx",
      "meta/instanceID": "uuid:44113165-acdf-448d-b984-f5952d10974b",
      "formhub/uuid": "03788f6c0cab449aa6e2de65ad271382",
      "end": "2021-05-05T08:58:19.349-07:00",
      "_submission_time": "2021-05-05T15:58:22",
      "_attachments": [
        {
          "mimetype": "image/jpeg",
          "download_small_url": "https://kc.kobotoolbox.org/media/small?media_file=joshuaberetta%2Fattachments%2F03788f6c0cab449aa6e2de65ad271382%2F44113165-acdf-448d-b984-f5952d10974b%2Fimage-8_58_16.jpg",
          "download_large_url": "https://kc.kobotoolbox.org/media/large?media_file=joshuaberetta%2Fattachments%2F03788f6c0cab449aa6e2de65ad271382%2F44113165-acdf-448d-b984-f5952d10974b%2Fimage-8_58_16.jpg",
          "download_url": "https://kc.kobotoolbox.org/media/original?media_file=joshuaberetta%2Fattachments%2F03788f6c0cab449aa6e2de65ad271382%2F44113165-acdf-448d-b984-f5952d10974b%2Fimage-8_58_16.jpg",
          "filename": "joshuaberetta/attachments/03788f6c0cab449aa6e2de65ad271382/44113165-acdf-448d-b984-f5952d10974b/image-8_58_16.jpg",
          "instance": 94571949,
          "download_medium_url": "https://kc.kobotoolbox.org/media/medium?media_file=joshuaberetta%2Fattachments%2F03788f6c0cab449aa6e2de65ad271382%2F44113165-acdf-448d-b984-f5952d10974b%2Fimage-8_58_16.jpg",
          "id": 33444831,
          "xform": 672795
        }
      ],
      "start": "2021-05-05T08:58:06.698-07:00",
      "_geolocation": [
        null,
        null
      ],
      "_status": "submitted_via_web",
      "__version__": "vLoBqVZebAJpZcDw9kb37c"
    }
  ]
}
1 Like

Thank you… :wink:

2 Likes