You can call GetBucketPolicy to query the policies configured for a specified bucket.
Request syntax
GET /? policy
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue
Request headers
All headers in a GetBucketPolicy request are common request headers. For more information, see Common request headers.
Response headers
All headers in the response to a GetBucketPolicy request are common response headers. For more information, see Common response headers.
Examples
Sample requests
GET /? policy Host: oss-example.oss-cn-hangzhou.aliyuncs.com Date: Thu, 17 Apr 2025 09:09:13 GMT Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e
Sample responses
HTTP/1.1 200 OK server: AliyunOSS x-oss-server-time: 24 connection: keep-alive x-oss-request-id: 5C6E9847BE0EBCD13DA90C11 date: Thu, 21 Feb 2019 12:23:35 GMT content-type: application/json { "Version":"1", "Statement":[ { "Action":[ "oss:PutObject", "oss:GetObject" ], "Effect":"Deny", "Principal":["1234567890"], "Resource":["acs:oss:*:1234567890:*/*"] } ] }
OSS SDKs
You can use OSS SDKs for the following programming languages to call the GetBucketPolicy operation:
ossutil
For information about the ossutil command that corresponds to the GetBucketPolicy operation, see get-bucket-policy.
Error codes
Error code | HTTP status code | Description |
NoSuchBucketPolicy | 404 | No policy is configured for the requested bucket. |