
# 查询企业组织结构-ListEnterpriseOrganizations
#### 功能介绍
企业主账号在自建平台查询企业组织结构。
#### 接口约束
该接口只允许使用企业主账号AK/SK或者Token调用。
#### 调试
您可以在[API Explorer](https://apiexplorer.developer.huaweicloud.com/apiexplorer/doc?product=BSS&api=ListEnterpriseOrganizations)中调试该接口。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[策略授权参考](https://support.huaweicloud.com/api-oce/jac_000053.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项                                  | 描述           | 访问级别 | 资源类型（\*为必须） | 条件键 | 别名 |
  |:---|:---|:---|:---|:---|:---|
  | businessUnitCenter:businessUnit:view | 授予查看组织与账号的权限 | read | -           | -   | -  |
     
  
 
#### URI
GET /v2/enterprises/multi-accounts/enterprise-organizations
参数说明请参见下表。
表1查询参数 
| 参数              | 是否必选 | 参数类型    | 取值范围    | 描述                                                                                                                                                                                                                                                           |
|:---|:---|:---|:---|:---|
| recursive_query | 否    | Integer | -       | 是否递归查询。 - 0：不递归（默认）  - 1：递归   如果不递归，只返回起始节点的直接子节点。 此参数不携带或携带值为空时，不作为筛选条件。 |
| parent_id       | 否    | String  | 最大长度：20 | 指定的节点ID。为空则从根节点查起。 此参数不携带或携带值为空时，不作为筛选条件。 说明： 此参数须由纯数字组成。                                                                                                                   |
   
#### 请求消息
**请求参数**
无。
**请求示例**
```
GET https://bss.myhuaweicloud.com/v2/enterprises/multi-accounts/enterprise-organizations?recursive_query=1&parent_id=392 HTTP/1.1
Content-Type: application/json
X-Auth-Token：MIIPAgYJKoZIhvcNAQcCo...ggg1BBIINPXsidG9rZ
```
#### 响应消息
**响应参数**
| 参数          | 参数类型                  | 取值范围      | 描述                                                                                                           |
|:---|:---|:---|:---|
| error_code  | String                | 最大长度：20   | 状态码。具体请参考[状态码]，只有失败才返回该字段。                                                 |
| error_msg   | String                | 最大长度：1000 | 错误描述信息。只有失败才返回该字段。                                                                                           |
| root_id     | String                | 最大长度：20   | 根节点ID，如果请求有parent_id，则该参数无值。                                                                                 |
| root_name   | String                | -         | 根节点名称，如果请求有parent_id，则该参数无值。 说明： 组织根节点没有设置组织名称时，可能为空。 |
| child_nodes | List\<EmChildNodeV2\> | -         | 企业管理子Party节点列表，具体参考[表2]。                                                       |
   
 表2EmChildNodeV2 
| 参数          | 参数类型                  | 取值范围    | 描述                    |
|:---|:---|:---|:---|
| relation_id | String                | 最大长度：20 | 实体关系ID。               |
| id          | String                | 最大长度：20 | 节点ID（即组织单元的Party ID）。 |
| name        | String                | -       | 节点名称。                 |
| child_nodes | List\<EmChildNodeV2\> | -       | 子节点列表。                |
   
**响应示例**
```
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: length
Date: response time  
{
    "root_id": null,
    "root_name": null,
    "child_nodes": [
        {
            "relation_id": "849",
            "id": "933",
            "name": "组织",
            "child_nodes": []
        },
        {
            "relation_id": "734",
            "id": "817",
            "name": "组织1",
            "child_nodes": [
                {
                    "relation_id": "735",
                    "id": "818",
                    "name": "组织2",
                    "child_nodes": []
                },
                {
                    "relation_id": "736",
                    "id": "819",
                    "name": "组织3",
                    "child_nodes": []
                },
                {
                    "relation_id": "740",
                    "id": "823",
                    "name": "组织4",
                    "child_nodes": []
                },
                {
                    "relation_id": "741",
                    "id": "824",
                    "name": "组织5",
                    "child_nodes": []
                }
            ]
        }
    ]
}
```
 #### 状态码
![](https://support.huaweicloud.com/api-oce/public_sys-resources/note_3.0-zh-cn.png)
- 状态码4xx：由于明显的客户端错误（例如，格式错误的请求语法、参数错误等），华为云会返回4xx错误码，请及时检查请求消息的正确性，重新发起请求。
- 状态码5xx：由于华为云系统原因，导致无法完成明显有效请求的处理，可及时联系华为云客服处理。
 
| HTTP状态码 | 错误码      | 错误描述  |
|:---|:---|:---|
| 400     | CBC.0100 | 参数错误。 |
| 403     | CBC.0151 | 访问拒绝。 |
| 500     | CBC.0999 | 其他错误。 |
   
