I’m trying to get PATCHes working against an Omeka-S 2.1.2 installation. I find that a simple curl test appears to be accepted (Omeka returns a 200), but the item is unchanged.

So, my first question: is JSON Patch the right syntax for the patch? If not, what should I use?

Here is a simple test, using curl. I’m able to create items with curl using POST, so I know the basic API framework is working. In this example I’m just trying to update the o:title of an item from “Peter at Fountains Abbey” to “Patched title”. The returned payload shows that it is unchanged.

$ curl -vs -X PATCH -H 'Content-type: application/json' --data-raw \
'[{"op": "replace", "path": "/o:title", "value": "Patched title"}]' \
"" > curltest.txt 2>&1

> PATCH /api/items/11?key_identity=xxxxxx&key_credential=yyyyyy HTTP/1.1
> Host:
> User-Agent: curl/7.52.1
> Accept: */*
> Content-type: application/json
> Content-Length: 65
} [65 bytes data]
* upload completely sent off: 65 out of 65 bytes
{ [5 bytes data]
< HTTP/1.1 200 OK
< Date: Thu, 20 Aug 2020 18:18:50 GMT
< Server: Apache
< Omeka-S-Version: 2.1.2
< Cache-Control: max-age=172800
< Expires: Sat, 22 Aug 2020 18:18:50 GMT
< Vary: User-Agent
< Transfer-Encoding: chunked
< Content-Type: application/json; charset=utf-8
{ [5 bytes data]
* Curl_http_done: called premature == 0
* Connection #0 to host left intact
{"@context":"https:\/\/\/api-context","@id":"https:\/\/\/api\/items\/11","@type":"o:Item","o:id":11,"o:is_public":true,"o:owner":{"@id":"https:\/\/\/api\/users\/1","o:id":1},"o:resource_class":null,"o:resource_template":null,"o:thumbnail":null,"o:title":"Peter at Fountains Abbey","o:created":{"@value":"2020-08-14T21:11:12+00:00","@type":"http:\/\/\/2001\/XMLSchema#dateTime"},"o:modified":{"@value":"2020-08-20T18:18:50+00:00","@type":"http:\/\/\/2001\/XMLSchema#dateTime"},"o:media":[{"@id":"https:\/\/\/api\/media\/13","o:id":13}],"o:item_set":[],"dcterms:title":[{"type":"literal","property_id":1,"property_label":"Title","is_public":true,"@value":"Peter at Fountains Abbey"}],"dcterms:description":[{"type":"literal","property_id":4,"property_label":"Description","is_public":true,"@value":"A man walks below broken gothic arches"}],"dcterms:type":[{"type":"literal","property_id":8,"property_label":"Type","is_public":true,"@value":"Image"}],"dcterms:creator":[{"type":"literal","property_id":2,"property_label":"Creator","is_public":true,"@value":"Elizabeth Wall"}],"dcterms:identifier":[{"type":"literal","property_id":10,"property_label":"Identifier","is_public":true,"@value":"pfountains3"}],"o-module-mapping:marker":[{"@id":"https:\/\/\/api\/mapping_markers\/1","o:id":1}]}

After some trial and error, this is the kind of body I sent with the call that I used to e.g. update title and description via PATCH:

  "@value":"Test patched title"},
  "@value":"Test description"}

All other things look alright to me.

Thank you so much! I was on the wrong track completely, both with using JSON Patch and in not understanding the relationship between o: and dcterms: fields. For the benefit of anyone as confused as I was: to do what I was trying to do, this works:

curl -vs -X PATCH -H 'Content-type: application/json' --data-raw \
'[{"dcterms:title": {"type":"literal","property_id":1,"property_label":"Title","is_public":true,\
"@value":"Patched title"}}]' \

But it leads to deleting all the other dcterms: fields I had set, such as dcterms:description (i.e. RDF properties), as explained (but not understood by me) in the docs.

1 Like

Yes, I should have clarified that all other metadata are deleted! Which is why in practice I feel that the process for editing items via the API is mostly a two step process: first get the data from the API, change whatever you want to change, and then send them all back via PATCH.

This topic was automatically closed 250 days after the last reply. New replies are no longer allowed.