Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
POSTing items to the DSpace 6 REST API

POSTing an item to /collections

First log in to get the JSESSIONID cookie and then post the item (I'm using httpie instead of curl):

$ http -f POST password=fuuuu
$ http POST Cookie:JSESSIONID=EABAC9EFF942028AA52DFDA16DBCAFDE < item-object.json
HTTP/1.1 200 OK
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json
Date: Wed, 07 Oct 2020 10:50:58 GMT
Server: nginx
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Robots-Tag: none
X-XSS-Protection: 1; mode=block

    "archived": "false",
    "bitstreams": null,
    "expand": [
    "handle": null,
    "lastModified": "Wed Oct 07 12:50:58 CEST 2020",
    "link": "/rest/items/335530b9-ed0e-4616-b81b-25cd3f14f9e9",
    "metadata": null,
    "name": "Testing REST API post",
    "parentCollection": null,
    "parentCollectionList": null,
    "parentCommunityList": null,
    "type": "item",
    "uuid": "335530b9-ed0e-4616-b81b-25cd3f14f9e9",
    "withdrawn": "false"

The response indicates that a new item has been created, and you get the internal UUID, but no Handle, because it hasn't been "archived" into the repository yet. If you post to a collection without a workflow then it will be archived automatically and you will get a Handle.

The item-object.json file looks like this:

{ "metadata": [
      "key": "dc.title",
      "value": "Testing REST API post",
      "language": "en_US"
      "key": "",
      "value": "Orth, Alan",
      "language": "en_US"
      "key": "",
      "value": "2020-09-01",
      "language": "en_US"

The archived and withdrawn keys seem to only be used for GETing items, not POSTing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment