GetBucketLocation

Updated at:
Copy as MD

Queries the region of an OSS bucket. Only the bucket owner can call this operation.

Request syntax

GET /?location HTTP/1.1
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue

Request headers

DescribeRegions uses only common request headers. For more information, see Common request headers.

Response headers

The response contains only common response headers. For more information, see Common response headers.

Response elements

Element

Type

Example

Description

LocationConstraint

String

oss-cn-hangzhou

The region ID of the bucket, such as oss-cn-hangzhou.

Examples

Request example

Get /?location HTTP/1.1
Host: examplebucket.oss-cn-hangzhou.aliyuncs.com
Date: Thu, 17 Apr 2025 05:31:04 GMT  
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e          

Success response example

HTTP/1.1 200
x-oss-request-id: 534B371674E88A4D8906****
Date: Fri, 15 Mar 2013 05:31:04 GMT
Connection: keep-alive
Content-Length: 90 
Server: AliyunOSS

<?xml version="1.0" encoding="UTF-8"?>
<LocationConstraint>oss-cn-hangzhou</LocationConstraint >

OSS SDKs

Call GetBucketLocation with the following OSS SDKs:

Error codes

Error code

HTTP status code

Description

AccessDenied

403

You do not have permissions to query the bucket region. Only the bucket owner can perform this operation.