# Team members

A team's members and their roles: make a member an owner, and list the owners with $filter on roles.

A team's member list shows who belongs to the team and each member's `roles`. Load the `teams_launch_hub` scenario and list the team's owners:

```bash
H='Authorization: Bearer placeholder-token'
J='Content-Type: application/json'
curl -s -o /dev/null -w '%{http_code}\n' -X POST "$RYSTIC_URL/_rystic/scenario" -d '{"name":"teams_launch_hub"}'
# -> 204
MEMBERS="$RYSTIC_URL/v1.0/teams/3dd52548-ef0b-41b9-896b-e62254b098ed/members"
curl -s "$MEMBERS" -H "$H" | jq -c '[.value[] | {displayName, roles}]'
# -> [{"displayName":"Priya Nair","roles":["owner"]},{"displayName":"Hannah Weiss","roles":[]},{"displayName":"Aiko Tanaka","roles":[]},{"displayName":"Diego Santos","roles":[]},{"displayName":"Marcus Feld","roles":["owner"]}]
curl -s -G "$MEMBERS" -H "$H" --data-urlencode "\$filter=roles/any(r:r eq 'owner')" | jq -c '[.value[].displayName]'
# -> ["Priya Nair","Marcus Feld"]
```

A member with an empty `roles` list is a plain member. `$filter` reads one property, `roles`, through `any` or `all` with `eq`.

### Make a member an owner

A `PATCH` with `roles` changes the member's role, and the owner filter follows:

```bash
HANNAH=$(curl -s "$MEMBERS" -H "$H" | jq -r '.value[] | select(.displayName == "Hannah Weiss") | .id')
curl -s -X PATCH "$MEMBERS/$HANNAH" -H "$H" -H "$J" -d '{"@odata.type":"#microsoft.graph.aadUserConversationMember","roles":["owner"]}' | jq -c '{displayName, roles}'
# -> {"displayName":"Hannah Weiss","roles":["owner"]}
curl -s -G "$MEMBERS" -H "$H" --data-urlencode "\$filter=roles/any(r:r eq 'owner')" | jq -c '[.value[].displayName]'
# -> ["Priya Nair","Hannah Weiss","Marcus Feld"]
```

### List everyone but the owners

A `not` around `any` lists the plain members (unconfirmed: not yet checked against Microsoft Graph):

```bash
curl -s -G "$MEMBERS" -H "$H" --data-urlencode "\$filter=not(roles/any(r:r eq 'owner'))" | jq -c '[.value[].displayName]'
# -> ["Aiko Tanaka","Diego Santos"]
```

**Differs from Microsoft Graph:** `roles/all(r:r eq 'owner')` also lists members whose `roles` list is empty, where Microsoft Graph lists only the owners.

```bash
curl -s -G "$MEMBERS" -H "$H" --data-urlencode "\$filter=roles/all(r:r eq 'owner')" | jq -c '[.value[].displayName]'
# -> ["Priya Nair","Hannah Weiss","Aiko Tanaka","Diego Santos","Marcus Feld"]
```

### Test a refused list query

The member list returns 400 for these queries:

| Query | `error.code` |
|---|---|
| `roles eq 'owner'`, outside `any` or `all` | `BadRequest` |
| `$orderby=roles` | `BadRequest` |
| `$count=true` | empty |

```bash
curl -s -G "$MEMBERS" -H "$H" --data-urlencode "\$filter=roles eq 'owner'" | jq -c '.error.code'
# -> "BadRequest"
curl -s -G "$MEMBERS" -H "$H" --data-urlencode '$orderby=roles' | jq -c '.error'
# -> {"code":"BadRequest","message":"The query specified in the URI is not valid. The $orderby expression must evaluate to a single value of primitive type."}
curl -s -G "$MEMBERS" -H "$H" --data-urlencode '$count=true' | jq -c '.error | {code, message}'
# -> {"code":"","message":"The query specified in the URI is not valid. Query option 'Count' is not allowed. To allow it, set the 'AllowedQueryOptions' property on EnableQueryAttribute or QueryValidationSettings."}
```

**Differs from Microsoft Graph:** the two `BadRequest` refusals have a different `error.message` from Microsoft Graph's.

**Differs from Microsoft Graph:** a filter on `displayName`, a `ne` comparison and an `or` that joins a `roles` clause with a `displayName` one return 400, where Microsoft Graph returns 200.

```bash
curl -s -o /dev/null -w '%{http_code}\n' -G "$MEMBERS" -H "$H" --data-urlencode "\$filter=displayName eq 'Priya Nair'"
# -> 400
curl -s -o /dev/null -w '%{http_code}\n' -G "$MEMBERS" -H "$H" --data-urlencode "\$filter=displayName ne 'Priya Nair'"
# -> 400
curl -s -o /dev/null -w '%{http_code}\n' -G "$MEMBERS" -H "$H" --data-urlencode "\$filter=roles/any(r:r eq 'owner') or displayName eq 'Aiko Tanaka'"
# -> 400
```

**Differs from Microsoft Graph:** `$orderby` on another property, such as `displayName`, returns 400 `BadRequest` with the `roles` message. Microsoft Graph returns 400 with an empty `error.code` and says the `OrderBy` option is not allowed.

```bash
curl -s -G "$MEMBERS" -H "$H" --data-urlencode '$orderby=displayName' | jq -c '.error'
# -> {"code":"BadRequest","message":"The query specified in the URI is not valid. The $orderby expression must evaluate to a single value of primitive type."}
```

---

Source: https://www.rystic.ai/docs/simulators/teams/features/team-members · Markdown: https://www.rystic.ai/docs/simulators/teams/features/team-members.md
