Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

curl command to add a value in a multi valued property of a particular node in CQ

Tags:

curl

aem

crx

I have a paticular node for eg : /content/site/advisors/jcr:content which consists of a property "cq:allowed templates" whose value consists of multiple string values(array of strings) .I want to add another string value into it using a curl command.Please suggest. enter image description here

like image 239
rishabh aggarwal Avatar asked Feb 09 '23 16:02

rishabh aggarwal


1 Answers

The @Patch suffix is used by the Sling POST servlet to add or remove values from a multi-value property, for example:

$ curl -u admin:admin -Fmulti@TypeHint="String[]" -Fmulti=one -Fmulti=two -Fmulti=four http://localhost:8080/test
$ curl -u admin:admin -Fmulti@Patch="true" -Fmulti="+three" -Fmulti="-four" http://localhost:8080/test

$ curl http://localhost:8080/test.tidy.json
{
  "jcr:primaryType": "nt:unstructured",
  "multi": [
    "one",
    "two",
    "three"
  ]
  }

The docs are at https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#patch

like image 197
Bertrand Delacretaz Avatar answered May 06 '23 00:05

Bertrand Delacretaz