Queries the Resource Access Management (RAM) user groups to which a RAM user belongs.

Description

This topic provides an example on how to query the RAM user groups to which the RAM user Alice belongs. The response shows that Alice belongs to the RAM user group named Dev-Team.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes ListGroupsForUser

The operation that you want to perform. Set the value to ListGroupsForUser.

UserName String Yes Alice

The username of the RAM user.

For more information about common request parameters, see Common parameters.

Response parameters

Parameter Type Example Description
RequestId String DA772B52-BF9F-54CA-AC77-AA7A2DA89D46

The ID of the request.

Groups Array of Group

The list of the RAM user groups.

Group
GroupId String g-zYtroLrgbZR1****

The ID of the RAM user group.

GroupName String Dev-Team

The name of the RAM user group.

Comments String Development team

The description of the RAM user group.

JoinDate String 2015-01-23T12:33:18Z

The time when the RAM user joined the RAM user group.

Examples

Sample requests

https://ram.aliyuncs.com/?Action=ListGroupsForUser
&UserName=Alice
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<ListGroupsForUserResponse>
    <RequestId>DA772B52-BF9F-54CA-AC77-AA7A2DA89D46</RequestId>
    <Groups>
        <Group>
            <GroupName>Dev-Team</GroupName>
            <Comments>Development team</Comments>
            <JoinDate>2015-01-23T12:33:18Z</JoinDate>
            <GroupId>g-zYtroLrgbZR1****</GroupId>
        </Group>
    </Groups>
</ListGroupsForUserResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "DA772B52-BF9F-54CA-AC77-AA7A2DA89D46",
  "Groups" : {
    "Group" : [ {
      "GroupName" : "Dev-Team",
      "Comments": "Development team",
      "JoinDate" : "2015-01-23T12:33:18Z",
      "GroupId" : "g-zYtroLrgbZR1****"
    } ]
  }
}

Error codes

For a list of error codes, visit the API Error Center.