The REST Web Services server will accept map and collection input when you set the values of properties that accept multiple values.

Unless you are setting the value of a repository item, you must specify the Java classes used for the container and the contents.

When you set the value of a non-repository, Nucleus component property, the REST Web Services server will replace all values with any new values that you set. To append a value to an existing collection, you must supply all the existing values along with the new values.

You can configure the way the REST Web Services server appends or replaces multiple values in a repository item property. See Appending Values to Repository Item Properties and Replacing Multiple Values in a Repository Item Property.

The following example shows a REST Web Services request that appends a value to a non-repository component property. It includes all existing values in the property along with the new value. To remove a value, make a similar request that includes only the values that you wish to remain in the property.

curl -v -b cookies.txt -X POST \
-H "Content-Type: application/json" \
-d "{'atg-rest-param-class-types':{'container-class':'java.util.ArrayList','element-class':'java.lang.String'},'arg1':['Existing String in the Collection','New String for the Collection']}" \
http://myserver:7003/rest/bean/atg/MyDog/tricks?atg-rest-json-input=true

See more information about setting property values in Setting Component Properties and Setting Repository Item Properties.

Specifying Java Classes for Multiple Value Input

Specify the Java classes for your array, collection, and map values as shown in the following table.

Value Type

Format

Array

<array-element-class>:[value1,value2,...,valueN]

For example:

java.lang.String:[foo,bar,baz]

Collection

<collection-container-class>:<element-class>:[value1,value2,...,valueN]

For example:

java.util.ArrayList:java.lang.String:[foo,bar,baz]

Map

<map-class>:<key-class>:<value-class>:[key1=value1,key2=value2,key3=value3]

For example:

java.util.HashMap:java.lang.String:java.lang.String:
[foo=soccer,bar=baseball,baz=football]

If your input is in JSON format, you can use the atg-rest-param-class-types control parameter to specify Java classes. The atg-rest-param-class-types parameter includes two components, container-class and element-class. Include this attribute in your JSON input as shown below.

{'atg-rest-param-class-types':{'container-class':'java.util.ArrayList','element-class':'java.lang.String'},'arg1':['sit','stay','speak']}

See information about the atg-rest-param-class-types parameter in the Control Parameter Reference.

Appending Values to Repository Item Properties

To append data to a repository item property that holds multiple values, set the new value as you would for a single value property. See Setting Repository Item Properties.

The following example adds two repository item reference values to a repository item property that can hold multiple values. Any existing values in that property will remain there.

curl -v -b cookies.txt -X POST \
-H "Content-Type: application/xml" \
-d "<parameters><arg1>/atg/commerce/gifts/Giftlists/gift-list/gl40050,/atg/commerce/gifts/Giftlists/gift-list/gl40052</arg1></parameters>" \
http://myserver:8080/rest/repository/atg/userprofiling/ProfileAdapterRepository/user/130001/giftlists

Note: The REST Web Services server is configured to append values to repository item properties that accept multiple values by default. The appendMultiValuesByDefault configuration property controls this behavior for repository item properties. If you have reconfigured this setting, set the atg-rest-append-multi-values control parameter to true for each REST Web Services request that should append the new value. See appendMultiValuesByDefault.

Replacing Multiple Values in a Repository Item Property

To replace all the existing values in a repository item property that holds multiple values, include the atg-rest-append-multi-values control parameter with your REST Web Services request. Set the value of the control parameter to false.

Note: You can only use the rest-append-multi-values control parameter with repository item properties. It does not affect the way you can update non-repository properties.

The following example replaces all the values that are currently in a repository item property that holds multiple values. Only the repository item reference that is in the functional parameter will remain in the property.

curl -v -b cookies.txt -X POST \
-H "Content-Type: application/xml" \
-d "<parameters><arg1>/atg/commerce/gifts/Giftlists/gift-list/gl40049</arg1></parameters>" \
http://myserver:8080/rest/repository/atg/userprofiling/ProfileAdapterRepository/user/130001/giftlists?atg-rest-append-multi-values=false
JSON Markup Input for Multiple Value Repository Item Properties

If you are setting multiple values in a repository item property, you can use standard JSON markup for the collection or map value. Include the atg-rest-json-input with your REST Web Service request and set its value to true.

You can include JSON markup for multiple values in any input format. The following example shows a REST Web Services request that includes a JSON collection in an XML message body parameter.

curl.exe -v -b cookies.txt -X POST \
-H "Content-Type: application/xml" \
-d "<parameters><arg1>[ "/atg/commerce/gifts/Giftlists/gift-list/gl40050", "/atg/commerce/gifts/Giftlists/gift-list/gl40052" ]</arg1></parameters>" \
http://myserver:8080/rest/repository/atg/userprofiling/ProfileAdapterRepository/user/130001/giftlists?atg-rest-json-input=true