REST API PATCH replace whole field value behaviour

26 views
Skip to first unread message

h.sid...@unsw.edu.au

unread,
May 9, 2025, 7:23:59 AM5/9/25
to DSpace Technical Support
Hi All,

I am current testing the REST API PATCH on /items end point to replace the whole field with new list. I am trying to replace dc:subject with a new list. For example:

The Item has three dc:subject: keyword1, keyword2 keyword3.
Using the json below to replace the whole dc:subject.
The result show only the first value has been added dc:subject: test1
[
  {
    "op": "replace",
    "path": "/metadata/dc.subject",
    "value":[
        {"value" : "test1"},
        {"value" : "test2"},
        {"value" : "test3"}
    ]    
  }
]
Can we replace the whole field? What is the issue on the json above?

I have tried to test with full properties (language,authority,place), and still show the same behavior.


Best regards,

Harry


h.sid...@unsw.edu.au

unread,
May 12, 2025, 4:40:28 AM5/12/25
to DSpace Technical Support
Just an update on my end.
Because there is no response, It seems that the replace as shown previously is not supported, at this stage.
The way to do the replace currently is to include the op:remove first then op:add for each as shown below.
Hope this helps.
FYI:
- The minus on subject to ensure that it is added after the first subject, otherwise the order will be in reverse.
- This is tested on version 7 and 8. Both seems have to be done as below.

[
  {
    "op": "remove",
    "path": "/metadata/dc.subject"
  },
  {
    "op": "add",
    "path": "/metadata/dc.subject",
    "value":"test1"
  },
  {
    "op": "add",
    "path": "/metadata/dc.subject/-",
    "value":"test2"
  },
  {
    "op": "add",
    "path": "/metadata/dc.subject/-",
    "value":"test3"
  }
]


Best regards,

Harry Sidhunata
UNSW Sydney Library
Reply all
Reply to author
Forward
0 new messages