使用Pulsar Admin Rest API获取sample/standalone/ns1命名空间策略遇405错误求解
sample/standalone/ns1 The 405 error you’re hitting boils down to how URL path separators clash with Pulsar’s hierarchical namespace naming. Let’s break this down and get it fixed:
Why the error happens
When you send a request to /admin/v2/namespaces/sample/standalone/ns1, the Pulsar API misinterprets the path structure:
- It reads
sampleas the tenant (correct) - It reads
standaloneas the full namespace (wrong) - It sees
ns1as an extra, unrecognized path segment
Since there’s no API endpoint that matches /admin/v2/namespaces/{tenant}/{namespace}/{extra}, the server returns a 405 Method Not Allowed (a common fallback when the requested path doesn’t map to any valid endpoint).
Your core understanding of the tenant/namespace split is correct (sample is the tenant, standalone/ns1 is the namespace) — the problem is that the slash in standalone/ns1 is being treated as a URL path divider instead of part of the namespace name.
How to fix it
You need to URL-encode the slash (/) in the namespace name as %2F. This tells the API that the slash is part of the namespace parameter, not a path separator.
Correct API URL
Use this formatted URL instead:
/admin/v2/namespaces/sample/standalone%2Fns1
Double-check your HTTP method
Make sure you’re using the GET method (required for fetching namespace policies). Since your request to public/default works, your method is likely correct — but it’s worth confirming you didn’t accidentally use POST/PUT/DELETE for the sample/standalone/ns1 request.
Example working curl command
Here’s a quick test to validate the fix:
curl -X GET http://your-pulsar-admin-host:8080/admin/v2/namespaces/sample/standalone%2Fns1
This should return the namespace policies for sample/standalone/ns1 without the 405 error.
内容的提问来源于stack exchange,提问作者NickNgn

