PutAttributes

Description

The PutAttributes operation creates or replaces attributes in an item. You specify new attributes using a combination of the Attribute.X.Name and Attribute.X.Value parameters. You specify the first attribute by the parameters Attribute.0.Name and Attribute.0.Value, the second attribute by the parameters Attribute.1.Name and Attribute.1.Value, and so on.

Attributes are uniquely identified in an item by their name/value combination. For example, a single item can have the attributes { "first_name", "first_value" } and { "first_name", second_value" }. However, it cannot have two attribute instances where both the Attribute.X.Name and Attribute.X.Value are the same.

Optionally, the requestor can supply the Replace parameter for each individual attribute. Setting this value to true causes the new attribute value to replace the existing attribute value(s). For example, if an item has the attributes { 'a', '1' }, { 'b', '2'} and { 'b', '3' } and the requestor calls PutAttributes using the attributes { 'b', '4' } with the Replace parameter set to true, the final attributes of the item are changed to { 'a', '1' } and { 'b', '4' }, which replaces the previous values of the 'b' attribute with the new value.

[Note]Note

Using PutAttributes to replace attribute values that do not exist will not result in an error response.

You cannot specify an empty string as an attribute name.

Because Amazon SimpleDB makes multiple copies of your data and uses an eventual consistency update model, an immediate GetAttributes or Select request (read) immediately after a DeleteAttributes request (write) might not return the updated data.

The following limitations are enforced for this operation:

  • 256 total attribute name-value pairs per item

  • One billion attributes per domain

  • 10 GB of total user data storage per domain

Request Parameters

Name Description Required

Attribute.X.Name (REST)

<Attribute><Name>... </Name></Attribute> (SOAP)

The name of the attribute.

Type: String.

Yes

Attribute.X.Value (REST)

<Attribute><Value>... </Value></Attribute> (SOAP)

The value of the attribute.

Type: String.

Yes
ItemName

The name of the item.

Type: String.

Yes

Attribute.X.Replace (REST)

<Attribute><Replace>... </Replace></Attribute> (SOAP)

Flag to specify whether to replace the Attribute/Value or to add a new Attribute/Value. The default setting is false.

Type: String.

No
DomainName

The name of the domain in which to perform the operation.

Type: String

Yes

Response Elements

See Common Response Elements.

Special Errors

Error Description
InvalidParameterValue Value (" + value + ") for parameter Name is invalid. Value exceeds maximum length of 1024.
InvalidParameterValue Value (" + value + ") for parameter Value is invalid. Value exceeds maximum length of 1024.
InvalidParameterValue Value (" + value + ") for parameter Item is invalid. Value exceeds max length of 1024.
InvalidParameterValue Value (" + value + ") for parameter Replace is invalid. The Replace flag should be either true or false.
MissingParameter The request must contain the parameter DomainName.
MissingParameter The request must contain the parameter ItemName.
MissingParameter Attribute.Value missing for Attribute.Name='<attribute name>'.
MissingParameter Attribute.Name missing for Attribute.Value='<attribute value>'.
NoSuchDomain The specified domain does not exist.
NumberItemAttributesExceeded Too many attributes in this item.
NumberDomainAttributesExceeded Too many attributes in this domain.
NumberDomainBytesExceeded Too many bytes in this domain.

Examples

Sample Request

The following example uses PutAttributes on Item123 which has attributes (Color=Blue), (Size=Med) and (Price=0014.99) in MyDomain. If Item123 already had the Price attribute, this operation would replace the values for that attribute.

https://sdb.amazonaws.com/
?Action=PutAttributes
&Attribute.0.Name=Color&Attribute.0.Value=Blue
&Attribute.1.Name=Size&Attribute.1.Value=Med
&Attribute.2.Name=Price&Attribute.2.Value=0014.99
&Attribute.2.Replace=true
&AWSAccessKeyId=[valid access key id]
&DomainName=MyDomain
&ItemName=Item123
&SignatureVersion=2
&SignatureMethod=HmacSHA256
&Timestamp=2007-06-25T15%3A03%3A05-07%3A00
&Version=2009-04-15
&Signature=[valid signature]

Sample Response

<PutAttributesResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15">
  <ResponseMetadata>
    <RequestId>490206ce-8292-456c-a00f-61b335eb202b</RequestId>
    <BoxUsage>0.0000219907</BoxUsage>
  </ResponseMetadata>
</PutAttributesResponse>