> ## 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.

# POST (/handles)

> POST (/handles)

# POST (/handles)

设置用户当前活动的多人游戏会话，并在需要时邀请会话成员。

> **重要：**\
> 此方法由 2015 多人游戏使用，仅适用于该多人游戏版本及更高版本。它旨在与模板协定 104/105 或更高版本一起使用，并且每个请求都需要一个 X-Xbl-Contract-Version: 104/105 或更高版本的头元素。

* [备注](#ID4ET)
* [URI 参数](#ID4EHB)
* [HTTP 状态代码](#ID4EPB)
* [请求正文](#ID4EVB)
* [响应正文](#ID4EJC)

## 备注

此 HTTP/REST 方法可用于设置当前活动的会话。在这种情况下，此方法可以由 **Microsoft.Xbox.Services.Multiplayer.MultiplayerService.SetActivityAsync** 包装。请求正文必须使用 JSON 文件中的 **sessionRef** 对象定义会话引用，且类型字段为 “activity”。不检索响应正文。有关会话引用中指定项的定义，请参阅 **Microsoft.Xbox.Services.Multiplayer.MultiplayerSessionReference**。

此 POST 方法还可用于邀请由句柄指定的用户加入会话。在这种情况下，此方法可以由 **Microsoft.Xbox.Services.Multiplayer.MultiplayerService.SendInvitesAsync** 包装。POST 方法的此用法要求您的请求正文定义会话引用，但类型字段设置为 “invite”。响应正文是一个邀请句柄。

## URI 参数

无

## HTTP 状态代码

服务返回适用于 MPSD 的 HTTP 状态代码。

## 请求正文

### 用于设置活动的请求正文

```cpp theme={null}
{
  "version": 1,
  "type": "activity",
  "sessionRef": {
    "scid": "bd6c41c3-01c3-468a-a3b5-3e0fe8133862",
    "templateName": "deathmatch",
    // The session name is optional in a POST; if not specified, MPSD fills in a GUID.//
    "name": "session-49"
  },
}

```

### 用于发送邀请的请求正文

```cpp theme={null}
{
  // Common handle fields
  "id: "47ca0049-a5ba-4bc1-aa22-fcf834ce4c13",
  "version": 1,
  "type": "invite",
  "sessionRef": {
    "scid": "bd6c41c3-01c3-468a-a3b5-3e0fe8133862",
    "templateName": "deathmatch",
    "name": "session-49"
   },
   "inviteAttributes": {
     "titleId" : {titleId}, // The title being invited to, in decimal uint32. This value is used to find the title name and/or image.
     "context" : {context}, // The title defined context token. Must be 256 characters or less when URI-encoded.
     "contextString" : {contextstring}, // The string name of a custom invite string to display in the invite notification.
     "senderString" : {sender} // The string name of the sender when the sender is a service.
   },
   "invitedXuid": "3210",
}

```

## 响应正文

### 用于设置活动的响应正文

无。

### 用于发送邀请的响应正文

邀请句柄。

## 另请参阅

##### 上级

[/handles](https://devdocs.xbox.com/zh-CN/reference/live/rest/uri/sessiondirectory/uri-handles)


## Related topics

- [PFLobbyPostUpdate](https://devdocs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pflobbypostupdate.md)
- [PFLobbyServerPostUpdate](https://devdocs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pflobbyserverpostupdate.md)
- [PFLobbyServerPostUpdateAsServer](https://devdocs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pflobbyserverpostupdateasserver.md)
