> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PUT /titles/{titleId}/users/{xuid}/activities

> Update Activity

# Update Activity

设置或更新用户在特定标题中的活动。
此 API 允许游戏客户端或服务器为在特定标题中游戏的用户设置/更新多玩家活动。当用户在多玩家活动中变为活动状态时,必须立即设置活动。XBOX Live 用户将能够订阅其他用户(通常是好友)的活动更改,这些更新将通过 RTA 推送到 XBOX 客户端。

```http theme={null}
PUT /titles/{titleId}/users/{xuid}/activities
```

## URI 参数

| 参数 | 位置 | 是否必需 | 类型 | 说明 |
| - | - | - | - | - |
| titleId | path | TRUE | integer | 发送请求所针对的游戏的 titleId。 |
| xuid | path | TRUE | string | 当前请求中引用的用户的 XUID。XUID 表示为十进制整数。 |

## 请求标头

| 名称 | 是否必需 | 类型 | 说明 |
| - | - | - | - |
| Authorization | TRUE | integer | 调用方必须以 XBL 3.0 授权格式提供 XToken。例如,Authorization: XBL3.0 x=2553948354698;\<encrypted token>) |
| Content-Type | TRUE | string | ContentType 必须设置为 application/json |

## 请求正文

| 名称 | 是否必需 | 类型 | 说明 |
| - | - | - | - |
| connectionString | TRUE | string | 连接字符串是传递给正在连接的客户端以加入游戏的对象。连接字符串通常包含服务器 IP 之类的信息,以使加入的用户能够进行连接。连接字符串的长度限制为 512 个字符。 |
| joinRestriction | TRUE | JoinRestriction | 用于设置谁可以加入当前玩家的选项。 |
| sequenceNumber | TRUE | string | 这是单调递增数字 (ulong) 的字符串表示形式,客户端必须为每个请求传递此值。它用于保证活动更新的顺序。sequenceNumber 的一个很好示例是客户端的 unix 时间,因为它保证是递增的。必须大于 0,且不能大于最大 ulong 值。 |
| currentPlayers | | integer | 已经与该用户一起在多玩家活动中游戏的玩家数。 |
| groupId | | string | 用于将作为同一场游戏一部分进行游戏的所有用户分组的唯一标识符。 |
| maxPlayers | | integer | 当前活动中可以与此玩家一起游戏的最大玩家数。 |
| platform | | [Platform](#platform) | |

## 响应

| 名称 | 类型 | 说明 |
| - | - | - |
| 204 No Content | | 活动已成功设置。 |
| 400 Bad Request | [ErrorResponse](#errorresponse) | 处理请求时发生错误。可能的错误代码:“RequestValidationError: The request validation has failed.”、“AuthorizationError: The caller is not allowed to access the resource. Too many requests.” |
| 其他状态代码 | [ThrottledEntity](#throttledentity) | 请求过多。标头 Retry-After: integer |

## 定义

* [ErrorResponse](#errorresponse)
* [JoinRestriction](#joinrestriction)
* [Platform](#platform)
* [SetActivityRequest](#setactivityrequest)
* [ThrottleEntity](#throttleentity)

### ErrorResponse

| 名称 | 类型 | 说明 |
| - | - | - |
| debugMessage | string | 可用于调试的、人类可读的错误消息版本。 |
| errorCode | string | 错误代码枚举。 |

### JoinRestriction

用于设置谁可以加入当前玩家的选项。

| 名称 | 类型 | 说明 |
| - | - | - |
| Followed | string | |
| InviteOnly | string | |
| Public | string | |

### Platform

| 名称 | 类型 | 说明 |
| - | - | - |
| Android | string | |
| IOS | string | |
| Nintendo | string | |
| PlayStation | string | |
| Scarlett | string | |
| Win32 | string | |
| WindowsOneCore | string | |
| XboxOne | string | |

## SetActivityRequest

如果请求中设置了活动的平台,则活动仅在该平台上可加入。如果未设置平台,则活动可在游戏可玩的所有平台上加入。

| 名称 | 类型 | 说明 |
| - | - | - |
| connectionString | string | 连接字符串是传递给正在连接的客户端以加入游戏的对象。连接字符串通常包含服务器 IP 之类的信息,以使加入的用户能够进行连接。连接字符串的长度限制为 512 个字符。 |
| currentPlayers | integer | 已经与该用户一起在多玩家活动中游戏的玩家数。 |
| groupId | string | 用于将作为同一场游戏一部分进行游戏的所有用户分组的唯一标识符。 |
| joinRestriction | [JoinRestriction](#joinrestriction) | 用于设置谁可以加入当前玩家的选项。 |
| maxPlayers | integer | 当前活动中可以与此玩家一起游戏的最大玩家数。 |
| platform | [Platform](#platform) | |
| sequenceNumber | string | 这是单调递增数字 (ulong) 的字符串表示形式,客户端必须为每个请求传递此值。它用于保证活动更新的顺序。sequenceNumber 的一个很好示例是客户端的 unix 时间,因为它保证是递增的。必须大于 0,且不能大于最大 ulong 值。 |

### ThrottledEntity

| 名称 | 类型 | 说明 |
| - | - | - |
| currentRequests | string | 当前请求数——并发或速率。 |
| debugMessage | string | 可用于调试的、人类可读的限流消息版本。 |
| limitType | string | 限制类型,即并发或速率。 |
| maxRequests | string | 允许的最大请求数——并发或速率。 |
| periodInSeconds | string | 超出速率或并发限制时适用的以秒为单位的时段。 |
| version | string | 当前限流合约版本。 |


## Related topics

- [Example code for Multiplayer Activity](https://devdocs.xbox.com/services/xbox-services/multiplayer/mpa/how-to/live-mpa-client-how-to.md)
- [Activities](https://devdocs.xbox.com/services/xbox-services/multiplayer/mpa/concepts/live-mpa-activities.md)
- [XblMultiplayerActivityDetails](https://devdocs.xbox.com/reference/live/xsapi-c/multiplayer_c/structs/xblmultiplayeractivitydetails.md)
- [XblTitleStorageUploadBlobAsync](https://devdocs.xbox.com/es/reference/live/xsapi-c/title_storage_c/functions/xbltitlestorageuploadblobasync.md)
