DSpace REST API - /items/find-by-metadata-field

616 views
Skip to first unread message

Filippo Santoro

unread,
Aug 28, 2018, 9:14:59 AM8/28/18
to DSpace Technical Support
Dear all,
I'm using the DSpace REST APIs for an external application. I have some difficult to use the end point /items/find-by-metadata-field to search an item based on a particular metadata.
In fact, using Postman with the following request:

http://server16.iss.it:8080/rest/items/find-by-metadata-field?key=dc.contributor.author&value=Petrini

I get an HTTP500 error (internal server error). What is the right syntax for using it?

Thanks in advance

Filippo

Alan Orth

unread,
Aug 29, 2018, 8:22:58 AM8/29/18
to santoro...@gmail.com, DSpace Technical Support
Hello, Filippo.

You need to POST a MetadataEntry object with the request[0]. For example, in DSpace 5.x this works:

$ curl -s -H "accept: application/json" -H "Content-Type: application/json" -X POST "http://server16.iss.it:8080/rest/items/find-by-metadata-field" -d '{"key": "dc.contributor.author","value": "Petrini"}'

Note that the API only returns exact text matches (no wildcard), and you will probably need to specify the language to actually match anything as well:

$ curl -s -H "accept: application/json" -H "Content-Type: application/json" -X POST "http://server16.iss.it:8080/rest/items/find-by-metadata-field" -d '{"key": "dc.contributor.author","value": "Petrini","language": "en_US"}'

The language can also be a literal null (without quotes). It all depends on how your metadata is entered into the database.


Cheers,

--
All messages to this mailing list should adhere to the DuraSpace Code of Conduct: https://duraspace.org/about/policies/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dspace-tech...@googlegroups.com.
To post to this group, send email to dspac...@googlegroups.com.
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.


--
Alan Orth
alan...@gmail.com
https://picturingjordan.com
https://englishbulgaria.net
https://mjanja.ch
"In heaven all the interesting people are missing." ―Friedrich Nietzsche
Reply all
Reply to author
Forward
0 new messages