4

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

rishabh aggarwal
  • 129
  • 1
  • 3
  • 9

2 Answers2

5

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

Bertrand Delacretaz
  • 6,100
  • 19
  • 24
3

Simply add multiple -Fproperty-name="property-value" with a additional TypeHint:

-Fproperty-name@TypeHint="String[]" -Fproperty-name="first property value" -Fproperty-name="second property value" etc.

chrysler
  • 448
  • 3
  • 5