4
votes

I am using Postman to send the AWS S3 RestAPI "Get Bucket (Version 2)" to get bucket listing.

Name of bucket is "test-bucket-1.ahadomain.com" (ahadomain.com is a dummy nonexistent domain that I used when naming the bucket in aws). The user credentials I am using has all the permissions to make S3 calls. I am following the info on page - http://docs.aws.amazon.com/AmazonS3/latest/API/v2-RESTBucketGET.html

I am using the endpoint : https://test-bucket-1.s3.us-east-1.amazonaws.com I am sending the following Headers : Content-Type, Host, X-Amz-Content-Sha256, X-Amz-Date, Authorization

Do I need to add "list-type" as a query parameter or as a header? If as a query parameter, how do I state it in the url.

I am getting the following response, which does not contain a listing of the content, just info about the bucket itself:

<?xml version="1.0" encoding="UTF-8"?>
<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <Owner>
        <ID>6893100ea2b48696e8ccc3aa17414f4325cf59b574474ad9de0bcb0d139590c9</ID>
        <DisplayName>ahmedsmail</DisplayName>
    </Owner>
    <Buckets>
        <Bucket>
            <Name>test-bucket-1.ahadomain.com</Name>
            <CreationDate>2017-09-06T06:36:15.000Z</CreationDate>
        </Bucket>
    </Buckets>
</ListAllMyBucketsResult>

Any help would be greatly appreciated.

Thank you, Ahmed.

2
https://test-bucket-1.s3.us-east-1.amazonaws.com Is not correct. That's someone else's bucket, and it happens to be disabled bucket... the service is interpreting your request as a request to list your buckets rather than your objects. You need to be using one of the endpoints for your buckets region: docs.aws.amazon.com/general/latest/gr/rande.html#s3_region with the bucket name in the path.Michael - sqlbot
Just curious, why/how ca you tell the the bucket is disabled? In my AWS console, the bucket "test-bucket-1.ahadomain.com" is listed in the US West(N. California) region. For this scenario I am using the following endpoint: test-bucket-1.s3-us-west-1.amazonaws.com Still getting same out, info on the bucket, not the contents. :(Ahmed A
Right, and I am telling you that your endpoint is incorrect. Your endpoint should be s3-us-west-1.amazonaws.com/test-bucket-1.ahadomain.com?list-type=2 or the entire bucket name to the left, test-bucket-1.ahadomain.com.s3-us-west-1.amazonaws.com. The other endpoint refers to a disabled bucket called simply "test-bucket-1" which is not your bucket, it's someone else's, and it appears to be disabled. Yours isn't.Michael - sqlbot
When I use URL - test-bucket-1.ahadomain.com.s3-us-west-1.amazonaws.com?list-typ…, I get message "There was an error connecting to ...." Basically an issue with the format of the URL. When I use URL - "s3-us-west-1.amazonaws.com/…", I get message saying I should use the URL with bucket name on the left (noted in the beginning of this comment). Is postman not able to use the URL with the bucket name on the left?Ahmed A
Bucket names with dots do not work on the left with https. Only http.Michael - sqlbot

2 Answers

16
votes

You can do the following:

  1. Set the method to GET
  2. in the URL: https://s3.amazonaws.com/test-bucket-1.ahadomain.com/?list-type=2
    Note: If the region of your bucket is not in us-east-1, change the s3.amazonaws.com to correct S3 endpoint of that region.
  3. In Authorization tab, set the following:
    a. Type: AWS Signature
    b. AccessKey:
    c. SecretKey:
    d. AWS Region: us-east-1
    Note: change this if this is not the region of your bucket
    e. Service Name: s3
    f. Check "Save helper data to request"
  4. Go to Headers tab, delete all entries if there is any.
  5. Then click "Send" button

Here sample result

0
votes

Selected Answer Absolutely works! Thank you

Tool:  Postman
function:  Get
Address:  https://s3.us-west-1.amazonaws.com/XXXXXXXX/?list-type=2
Region:  I am on us-west-1, **this is most common mistake people miss**. 

Looks like below, gets a 200

GET /XXXXXXXX/?list-type=2 HTTP/1.1 Host: s3.us-west-1.amazonaws.com Authorization: AWS4-HMAC-SHA256 Credential=XXXXXXXXXXXXXXXXX/00000000/us-west-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=;lkasdfl;kajsdfk;jasd;kfjas;ldkfjas;ldkfja;skjdf;askdjf;lkasdjf

-methods