Khachatur Saribekyan
Khachatur Saribekyan

Reputation: 97

How to create bucket in the AWS S3 via Postman

I used Postman AWS Signature to connect with S3 service and I could get all buckets, folder inside that bucket, also I could delete the bucket.

Here is a list of requests which I can do via Postman.

List of all bucket inside the specific region: GET    https://s3-us-west-2.amazonaws.com/
List of all objects/folders inside the bucket: GET    https://s3-us-west-2.amazonaws.com/<bucket name>
Delete the bucket/file (when it's empty):      DELETE https://s3-us-west-2.amazonaws.com/<bucket name>/[<file name>]
Create the file into the bucket:               PUT    https://s3-us-west-2.amazonaws.com/<bucket name>/[<file name>][<folder name>/]

When I want to create a bucket (PUT method), it's response me an error message.

The unspecified location constraint is incompatible for the region specific endpoint this request was sent to

So the question. How can I create bucket via Postman? Thanks in advance.

Upvotes: 2

Views: 2841

Answers (1)

Tom Nijs
Tom Nijs

Reputation: 3950

The documentation by AWS for creating a bucket through an API call mentions you can provide a location constraint in the body of the request:

<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> 
    <LocationConstraint>YourBucketRegion</LocationConstraint> 
</CreateBucketConfiguration>

Try adding it with the region of your choosing:

Valid Values: [ us-west-1 | us-west-2 | EU or eu-west-1 | 
eu-central-1 | ap-south-1 | ap-southeast-1 | ap-southeast-2 | 
ap-northeast-1 | ap-northeast-2 | sa-east-1 | us-east-2]

Here is the full syntax:

PUT / HTTP/1.1
Host: BucketName.s3.amazonaws.com
Content-Length: length
Date: date
Authorization: authorization string (see Authenticating Requests (AWS Signature Version
    4))

<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> 
<LocationConstraint>BucketRegion</LocationConstraint> 
</CreateBucketConfiguration>

Source: AWS Docs

Upvotes: 1

Related Questions