Updating metadata on an asset
This article describes how to update metadata on an asset using the API.
Syntax
PATCH asset URL Content-Type: application/vnd.fotoware.assetupdate+json Accept: application/vnd.fotoware.asset+json
The asset URL is the URL of the asset. It can be obtained by browsing an archive, through a search result, etc.
Requirements
Requires authentication: Yes
Required permissions: Edit Metadata on the archive containing the asset
Request body
The request must contain a body which describes which metadata fields shall be updated and what their values shall be. Example:
{ "metadata": { "5": { "value": "The Beatles" } } }
This request replaces the value of the metadata field 5 with the value "The Beatles". Other metadata fields are not modified and retain their previous values. See here for a reference of metadata field numbers.
It is possible to update multiple metadata fields in the same request:
{ "metadata": { "5": { "value": "The Beatles" }, "90": { "value": "London" } } }
This request replaces the values of the metadata fields 5 and 90 with different values.
Some metadata fields (bag fields) may contain multiple values. For such fields, multiple values can be given as a JSON array:
{ "metadata": { "5": { "value": "The Beatles" }, "25": { "value": [ "Paul", "John", "Ringo", "George" ] } } }
If only one value shall be added to a bag field, then the array brackets ([]
) can be omitted:
{ "metadata": { "5": { "value": "The Beatles" }, "25": { "value": "Paul" } } }
It is also possible to delete a metadata field by specifying empty array brackets:
{ "metadata": { "5": { "value": "The Ramones" }, "25": { "value": [] } } }
Request example using Curl
The following example is a CURL command line which sends a metadata update request to the API.
Before sending the request, create a text file called request.txt
, which contains the request body. You may use one of the examples above.
In the following CURL command, replace the URL (shown in bold) with the fully qualified URL of the asset. This URL can be obtained, for example, by visiting the details page of an asset in the browser and copying the address line (without the fragment part after #). If you obtained the URL using the API, remember adding http://
and the host name when using it in the following command line:
curl \ --header "Content-Type: application/vnd.fotoware.assetupdate+json" \ --header "Accept: application/vnd.fotoware.asset+json" \ --request PATCH http://fotoweb.acme.com/fotoweb/archives/5005-Photos/Incoming/0000.JPG.info \ -d @request.txt
Response data
If the request is successful, then the server sends the following response:
200 OK Content-Type: application/vnd.fotoware.asset+json { ... }
The response body (omitted here) is a complete JSON representation of the asset containing the updated metadata as well as the remaining metadata fields and other information.
Remarks
The API can be used to set the metadata fields that are defined in the metadata set of the archive containing the asset.