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.
Asked
Active
Viewed 2,973 times
4

rishabh aggarwal
- 129
- 1
- 3
- 9
-
1What have you done so far ? Please share some code. – thomasb Jul 03 '15 at 12:00
-
– Cris Rockwell Jul 04 '15 at 15:51
2 Answers
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