Get Organization List

根据Access Token列出当前用户所在的组织列表。

请求格式

GET https://{apigw-address}/app-portal-service/v2.2/user/organization/list

响应参数

名称

数据类型

描述

data

data结构体

组织列表。

data结构体

名称

数据类型

描述

organizations

IdNamePair结构体

组织列表详情。

IdNamePair结构体

名称

数据类型

描述

id

String

组织ID。

name

String

组织名称。

错误码

代码

描述

31401

提供的Access Token无效

示例

请求示例

url: https://{apigw-address}/app-portal-service/v2.2/user/organization/list

method: GET

headers: {"Authorization":"Bearer APP_PORTAL_S_TDKKeqfYBK3m5z3LRgKVqThWDYnRBN44"}

返回示例

{
  "code": 0,
  "message": "OK",
  "data": {
    "organizations": [
      {
        "id": "yourOrgId_1",
        "name": "rm_0726_001"
      },
      {
        "id": "yourOrgId_2",
        "name": "Portal Demo"
      }
    ]
  }
}

Java SDK 调用示例

public class AppPortalSdkTest{
    @Test
    public void getOrganizationListTest() {

        UserOrganizationListRequest userOrganizationListRequest = new UserOrganizationListRequest("your_access_token");
        UserOrganizationListResponse userOrganizationListResponse = Poseidon.config(PConfig.init().appKey("your_access_key").appSecret("your_secret_key").debug())
                .url("https://{apigw-address}").getResponse(userOrganizationListRequest, UserOrganizationListResponse.class);

        System.out.println("List organization res: " + JSON.toJSONString(userOrganizationListResponse));

        assertNotNull("Response should not be null", userOrganizationListResponse);
        assertNotNull("Response data should not be null", userOrganizationListResponse.data);
        assertNotNull("Organizations should not be null", userOrganizationListResponse.data.organizations);
        assertThat("Organizations should not be empty", userOrganizationListResponse.data.organizations, not(IsEmptyCollection.empty()));
    }
}