Metadata ******** This endpoint provides access to form metadata, for example, supporting documents, media files to be used in the form, source documents and map layers. - ``pk`` - primary key for the metadata - ``formid`` - the form id for a form - ``format`` - is the extension of a file format e.g ``png``, ``csv`` Permissions ----------- This endpoint applies the same permissions someone has on the form. Get list of metadata -------------------- Returns a list of metadata across all forms requesting user has access to. .. raw:: html
GET /api/v1/metadata:: HTTP 200 OK [ { "data_file": "", "data_file_type": null, "data_type": "public_link", "data_value": "http://mylink", "id": 406, "url": "https://api.ona.io/api/v1/metadata/406", "xform": 328 }, { "data_file": "username/form-media/a.png", "data_file_type": "image/png", "data_type": "media", "data_value": "a.png", "id": 7100, "url": "https://api.ona.io/api/v1/metadata/7100", "xform": 320 }, .... ] Get list of metadata for a specific form ----------------------------------------- The form endpoint, ``/api/v1/forms/formid``, contains a ``metadata`` field has list of metadata for the form. Alternatively, you can supply the query parameter ``xform`` with the `formid` as the value. .. raw:: html
GET /api/v1/metadata?xform=formid
::
HTTP 200 OK
[
{
"data_file": "username/form-media/a.png",
"data_file_type": "image/png",
"data_type": "media",
"data_value": "a.png",
"id": 7100,
"url": "https://api.ona.io/api/v1/metadata/7100",
"xform": 320
},
....
]
Get a specific metadata
------------------------
.. raw:: html
GET /api/v1/metadata/{pk}
::
curl -X GET https://api.ona.io/api/v1/metadata/7100
::
HTTP 200 OK
{
"data_file": "username/form-media/a.png",
"data_file_type": "image/png",
"data_type": "media",
"data_value": "a.png",
"id": 7100,
"url": "https://api.ona.io/api/v1/metadata/7100",
"xform": 320
}
If the metadata is a file, appending the extension of the file type would
return the file itself e.g:
.. raw:: html
GET /api/v1/metadata/{pk}.{format}
::
curl -X GET https://api.ona.io/api/v1/metadata/7100.png -o a.png
Alternatively, if the request is made with an ``Accept`` header of the
content type of the file the file would be returned e.g
.. raw:: html
GET /api/v1/metadata/{pk}
Accept: image/png
::
curl -X GET https://api.ona.io/api/v1/metadata/7100 -H "Accept: image/png" -o a.png
Add metadata or media file to a form
-------------------------------------
.. raw:: html
POST /api/v1/metadata*Payload* :: {"xform":
DELETE /api/v1/metadata/{pk}