aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

Missing required header for this request: x-amz-content-sha256

Open kw-andy opened this issue 10 years ago • 17 comments

I tried to do the following aws s3 sync s3://ottoman/1stfolder /home/ubuntu /s3-folder/*

I have this error

An error occurred (InvalidRequest) when calling the ListObjects operation: Missing required header for  this request: x-amz-content-sha256

Completed 1 part(s) with ... file(s) remaining

I configured my aws with aws configure

I checked on the net and I found this

 You explicitly opt in and set signature_version = s3v4 in your ~/.aws/config file.

I amended my file but I have the same error

kw-andy avatar Aug 26 '16 12:08 kw-andy

Can you show the --debug log for your request. There's a similar issue previously that was a result of an incorrect region: https://github.com/aws/aws-cli/issues/2112

Unsure you don't have an availability zone set to your region such as "us-west-2a" or "us-west-2b".

jamesls avatar Aug 26 '16 23:08 jamesls

Hi @jamesls I need to have a look. i'll do that this evening

kw-andy avatar Sep 01 '16 12:09 kw-andy

Ok, let us know if that didn't work for you and we'll reopen and take another look.

jamesls avatar Sep 02 '16 17:09 jamesls

I have the same issue. I have set signature_version = s3v4 in my config but that does not fix the error. Here is the debug trace:

Traceback (most recent call last):
  File "/usr/local/Cellar/awscli/1.11.1/libexec/lib/python2.7/site-packages/awscli/clidriver.py", line 186, in main
    return command_table[parsed_args.command](remaining, parsed_args)
  File "/usr/local/Cellar/awscli/1.11.1/libexec/lib/python2.7/site-packages/awscli/customizations/commands.py", line 190, in __call__
    parsed_globals)
  File "/usr/local/Cellar/awscli/1.11.1/libexec/lib/python2.7/site-packages/awscli/customizations/commands.py", line 187, in __call__
    return self._run_main(parsed_args, parsed_globals)
  File "/usr/local/Cellar/awscli/1.11.1/libexec/lib/python2.7/site-packages/awscli/customizations/s3/subcommands.py", line 473, in _run_main
    bucket, key, parsed_args.page_size, parsed_args.request_payer)
  File "/usr/local/Cellar/awscli/1.11.1/libexec/lib/python2.7/site-packages/awscli/customizations/s3/subcommands.py", line 500, in _list_all_objects
    for response_data in iterator:
  File "/usr/local/Cellar/awscli/1.11.1/libexec/lib/python2.7/site-packages/botocore/paginate.py", line 102, in __iter__
    response = self._make_request(current_kwargs)
  File "/usr/local/Cellar/awscli/1.11.1/libexec/lib/python2.7/site-packages/botocore/paginate.py", line 174, in _make_request
    return self._method(**current_kwargs)
  File "/usr/local/Cellar/awscli/1.11.1/libexec/lib/python2.7/site-packages/botocore/client.py", line 159, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/Cellar/awscli/1.11.1/libexec/lib/python2.7/site-packages/botocore/client.py", line 494, in _make_api_call
    raise ClientError(parsed_response, operation_name)
ClientError: An error occurred (InvalidRequest) when calling the ListObjects operation: Missing required header for this request: x-amz-content-sha256
2016-10-06 10:23:31,396 - MainThread - awscli.clidriver - DEBUG - Exiting with rc 255

ralinc avatar Oct 06 '16 07:10 ralinc

Ok, I found the problem. I had region = ireland in my config file while the correct one is region = eu-west-1.

ralinc avatar Oct 06 '16 07:10 ralinc

For benefit of other readers and Googlers, I too had a problem with region setting in config file. It was set to "region=us-east-1d" and that used to work. But obviously something has changed in the last few months because my S3 bucket is now reported to be in region=us-east-1, instead of region=us-east-1d. Edit and save fixed it.

tedsmith avatar Jan 28 '17 17:01 tedsmith

Upgrading to a more recent version of aws-cli did it for me.

zuk avatar Feb 15 '17 21:02 zuk

I still have the same problem with eu-central-1. us-east-1 works fine.

$ aws --version
aws-cli/1.11.83 Python/2.7.10 Darwin/16.5.0 botocore/1.5.46
$ aws s3api create-bucket --bucket test --region eu-central-1a

An error occurred (InvalidRequest) when calling the CreateBucket operation: Missing required header for this request: x-amz-content-sha256
$ aws s3api create-bucket --bucket test --region eu-central-1

An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.

kaskavalci avatar May 05 '17 12:05 kaskavalci

@kaskavalci Try: aws s3api get-bucket-location command and use sharp location from output.

Example:

{
    "LocationConstraint": "ap-southeast-1"
}

KES777 avatar May 31 '17 07:05 KES777

@KES777 it returns the eu-central-1 again?

{
    "LocationConstraint": "eu-central-1"
}

kaskavalci avatar May 31 '17 07:05 kaskavalci

some new servers which are deployed after 2014year support only V4 authorization. Try different region.

KES777 avatar Jun 02 '17 08:06 KES777

its because of the region settings. choose the accurate region. it will solve. I just resolved this issue.

hashamMunir avatar Jun 14 '17 12:06 hashamMunir

I ran into this because of a typo AWS_DEFAULT_REGION='use-east-1'. It would be really nice if the region were validated and returned an actionable error message rather than Missing required header for this request: x-amz-content-sha256.

Ely-S avatar Jul 19 '17 18:07 Ely-S

I get the same error, but in my case i am using REST

> <?xml version="1.0" encoding="UTF-8"?>
> <Error>
>     <Code>InvalidRequest</Code>
>     <Message>Missing required header for this request: x-amz-content-sha256</Message>
>     <RequestId>5C3A279EB972D5C1</RequestId>
>     <HostId>0UI3WZs487LL9Ce7FsGwazb6TmHIMEIcgMmTZjJPdEvzYkJuFCNxPp9gWyqZbXOjDT1ZvV/iwsg=</HostId>
> </Error>

pmatety avatar Mar 16 '18 17:03 pmatety

@pmatety , Even I got the same error while putting the object to the S3 bucket. How did you resolve the error?

SheikSena avatar Jul 16 '20 07:07 SheikSena

@SheikSena you must include an 'X-AMZ-CONTENT-SHA256' header with the sha256 hashed content.

lobotomisador avatar Jun 02 '22 17:06 lobotomisador

@SheikSena you must include an 'X-AMZ-CONTENT-SHA256' header with the sha256 hashed content.

I have the same error on us-east-1. I signed the request but do I need to add the hash content of the file that I trying to upload?

mvarelamobeats avatar Aug 11 '23 20:08 mvarelamobeats