POST a JSON object with your search terms:
$ curl -s -f -H "Content-Type: application/json" -X POST \
"https://dspacetest.cgiar.org/rest/items/find-by-metadata-field?expand=bitstreams" \
-d '{"key":"dcterms.subject", "value":"climate variability","language": "en_US"}' | \
python -m json.tool
...
A few notes:
- You must know the exact name of the metadata field, but this should be easy to find.
- The language is generally always
en_US
, which is an internal DSpace thing where theoretically metadata can be translated, but we rarely do that - The
expand
option is a feature of the REST API that allows you to include more information about each result. In this case I expand only the bitstreams (the less you expand, the faster and smaller the response). Include multiple expands with?expand=metadata,bitstreams
.
Iterate over the item responses and find the retrieveLink
for each item's bitstream:
{
"bundleName" : "THUMBNAIL",
"checkSum" : {
"checkSumAlgorithm" : "MD5",
"value" : "a619e57f0824c5c023a65e0425b9757d"
},
"description" : "IM Thumbnail",
"expand" : [
"parent",
"policies",
"all"
],
"format" : "JPEG",
"handle" : null,
"link" : "/rest/bitstreams/8cb37eee-cdc7-48be-9123-4b78777bf12d",
"mimeType" : "image/jpeg",
"name" : "OutcomesCaseStudySummary-CCAFS-P269-OICS2041.pdf.jpg",
"parentObject" : null,
"policies" : null,
"retrieveLink" : "/rest/bitstreams/8cb37eee-cdc7-48be-9123-4b78777bf12d/retrieve",
"sequenceId" : 4,
"sizeBytes" : 23739,
"type" : "bitstream",
"uuid" : "8cb37eee-cdc7-48be-9123-4b78777bf12d"
},
Profit.
@alanorth for my use case, I would need to pass an array of keywords (dcterms.subject). I am using the code below, but I am getting an error. Is this even possible, to retrieve entries using several metadata fields?