All Products
Search
Document Center

Object Storage Service:0002-00000427

Last Updated:Mar 27, 2025

Issue description

The value of the X-Amz-Content-SHA256 parameter in the request header is invalid.

Cause

You initiate a request that uses the Amazon S3-compatible V4 signature. However, the value of the X-Amz-Content-SHA256 parameter in the request header is invalid.

Example

The following code provides an example:

GET /test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=LTAI****************/20221220/us-east-1/s3/aws4_request&X-Amz-Date=20221220T084818Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=ab2***st HTTP/1.0
Date: Tue, 20 Dec 2022 08:48:18 GMT
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
X-Amz-Content-SHA256: ab***123
x-oss-s3-compat: true
  • If an HTTP method other than POST or PUT is used, the value of the X-Amz-Content-SHA256 parameter is the SHA-256 value of the empty string or UNSIGNED-PAYLOAD. In the preceding example, GET is used as the HTTP method.

  • If POST or PUT is used as the HTTP method, the value of the X-Amz-Content-SHA256 parameter is the SHA-256 value of the uploaded content.

Solution

Replace the value of the X-Amz-Content-SHA256 parameter with UNSIGNED-PAYLOAD and make sure that all parameters in the URL request are complete and valid values are specified for the parameters. The following code provides a correct example:

GET /test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=LTAI****************/20221220/us-east-1/s3/aws4_request&X-Amz-Date=20221220T084818Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=ab2s**** HTTP/1.0
Date: Tue, 20 Dec 2022 08:48:18 GMT
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
X-Amz-Content-SHA256: UNSIGNED-PAYLOAD
x-oss-s3-compat: true

We recommend that you use Amazon S3 SDKs to initiate the request. For more information, see Use Amazon S3 SDKs to access OSS.