Survey data

Create a new file on current asset

Fields:

  • asset (required)
  • user (required)
  • description (required)
  • file_type (required)
  • content (as binary) (optional)
  • metadata JSON (optional)

Notes:

  1. Files can have different types:
    • map_layer
    • form_media
  2. Files can be created with three different ways
    • POST a file with content parameter
    • POST a base64 encoded string with base64Encoded parameter<sup>1</sup>
    • POST an URL with metadata parameter<sup>2</sup>

<sup>1)</sup> metadata becomes mandatory and must contain filename property<br> <sup>2)</sup> metadata becomes mandatory and must contain redirect_url property

Files with form_media type must have unique filename per asset

post/api/v2/assets/{uid_asset}/files/

Request

  • The document declares no server URL.
  • Auth: one of:
    • HTTP basic
    • API key in header Authorization

Path parameters

uid_assetstring required

UID of the parent asset

Request body

OR
OR

Response

uidstring required
urlstring uri required
assetstring uri required
userstring uri required
user__usernamestring required
file_typestring required
descriptionstring required
date_createdstring date-time required
contentstring uri required

Example response

{
  "url": "https://kf.kobotoolbox.org/api/v2/assets/a3C9wWefqZVkChNLKqqXVZ/files/afSa8PqnoYe8vJqkrsGz3oN/",
  "asset": "https://kf.kobotoolbox.org/api/v2/assets/a3C9wWefqZVkChNLKqqXVZ/",
  "user": "https://kf.kobotoolbox.org/api/v2/users/bob/",
  "content": "https://kf.kobotoolbox.org/api/v2/assets/a3C9wWefqZVkChNLKqqXVZ/files/afSa8PqnoYe8vJqkrsGz3oN/content/"
}

Changes