Problem description
The PutBucketLifecycle request fails because the Expiration element in the request body XML is missing a required child element.
Causes
When ExpiredObjectDeleteMarker is absent from the Expiration element—or its value is false—you must include either Days or CreatedBeforeDate. Omitting both causes the request to fail.
Examples
The following request body triggers the error because the Expiration element contains no child elements:
PUT /?lifecycle HTTP/1.1
Host: oss-example.oss.aliyuncs.com
Content-Length: 336
Date: Mon , 6 May 2019 15:23:20 GMT
Authorization: OSS LTAI**************:77Dv****************
<?xml version="1.0" encoding="UTF-8"?>
<LifecycleConfiguration>
<Rule>
<ID>rule1</ID>
<Prefix>zzz</Prefix>
<Status>Enabled</Status>
<Expiration>
</Expiration>
</Rule>
</LifecycleConfiguration>Solutions
Add one of the following child elements to the Expiration element in the request body XML:
| Element | Description | Format |
|---|---|---|
Days | Number of days after the object's last modification date for the lifecycle rule to take effect | Integer |
CreatedBeforeDate | Cutoff date; OSS applies the lifecycle action to objects last modified before this date | yyyy-MM-ddT00:00:00.000Z (ISO 8601, UTC) |
Option 1: Use `Days`
PUT /?lifecycle HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Content-Length: 336
Date: Mon , 6 May 2019 15:23:20 GMT
Authorization: OSS LTAI**************:77Dv****************
<?xml version="1.0" encoding="UTF-8"?>
<LifecycleConfiguration>
<Rule>
<ID>rule1</ID>
<Prefix>zzz</Prefix>
<Status>Enabled</Status>
<Expiration>
<Days>200</Days>
</Expiration>
</Rule>
</LifecycleConfiguration>Option 2: Use `CreatedBeforeDate`
<?xml version="1.0" encoding="UTF-8"?>
<LifecycleConfiguration>
<Rule>
<ID>rule1</ID>
<Prefix>zzz</Prefix>
<Status>Enabled</Status>
<Expiration>
<CreatedBeforeDate>2024-01-01T00:00:00.000Z</CreatedBeforeDate>
</Expiration>
</Rule>
</LifecycleConfiguration>Alternatively, configure lifecycle rules in the OSS console to avoid constructing request bodies manually.