I am trying to list out projects using resourcemanager api. I am using the below code.
from google.cloud import resourcemanager
from google.cloud.resourcemanager import ProjectsClient
from google.oauth2 import service_account
path_json_file = "C:\\Users\\######\\Downloads\\dev-####-analyt-datal-svc- db.json"
credentials = service_account.Credentials.from_service_account_file(path_json_file)
client =resourcemanager.ProjectsClient(credentials=credentials)
print(client)
request = resourcemanager.ListProjectsRequest(
parent="###-amea-fldr/###-amea-analytics-fldr/##-amea-analytics-dev-fldr",
)
page_result = client.list_projects(request=request)
print(page_result)
I am using service account authentication. It has resourcemanager.projects.list permission also.
But I am getting the below error.
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Request contains an invalid argument."
debug_error_string = "{"created":"@1658894641.118000000","description":"Error received
from peer ipv6:[2404:6800:4007:809::200a]:443","file":"src/core/lib/surface/call.cc","file_line":967,"grpc_message":"Request contains an invalid argument.","grpc_status":3}"
Is this due to any error in the value passed to the argument "parent"?
Whether the way I have called the list_projects method is correct?
Yes, I think so.
See the definition of parent
in APIs Explorer for Cloud Resource Manager v3 projects.list
where you can try the API method (for your parameters) in the browser.
The parent
resource can be tricky but, the example cited on this page is folder/{folder}
.
I don't know because I don't have access to an org but you may be able to repeat the path ie /folder/{parent-folder}/folder/{child-folder}
.
Try permutations in the APIs Explorer.
If it works there, it'll work using the (any) client library.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.