> ## 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 (/batch)

> POST (/batch)

# POST (/batch)

POST 方法,用作跨多个标题、面向多个玩家统计信息的复杂批处理请求的 GET 方法。
这些 URI 的域为 `userstats.xboxlive.com`。

## 备注

标题开发者可以在 Partner Center 将统计信息标记为开放或受限。排行榜是开放统计信息。只要用户已获得对沙盒的授权,开放统计信息就可以由 Smartglass 以及 iOS、Android、Windows、Windows Phone 和 Web 应用程序访问。用户对沙盒的授权通过 Partner Center 管理。

* [备注](#ID4ET)
* [说明](#ID4EFB)
* [授权](#ID4EUB)
* [必需的请求标头](#ID4ETC)
* [可选的请求标头](#ID4E3D)
* [请求正文](#ID4EAF)
* [HTTP 状态代码](#ID4EWF)
* [响应正文](#ID4ENBAC)

## 说明

调用方提供一个消息正文,其中包含用户数组、服务配置 ID (SCID),以及每个 SCID 要检索的统计信息名称列表。

在阅读此更复杂的批处理模式页面之前,查看简单的单统计信息 [GET](https://devdocs.xbox.com/zh-CN/reference/live/rest/uri/userstats/uri-usersxuidscidsscidstatsget) 方法可能更有用。

## 授权

为内容隔离和访问控制场景实现了授权逻辑。

* 排行榜和用户统计信息都可以由任何平台上的客户端读取,前提是调用方在请求中提交有效的 XSTS 令牌。写入显然仅限于所支持的客户端。
* 标题开发者可以在 Partner Center 将统计信息标记为开放或受限。排行榜是开放统计信息。只要用户已获得对沙盒的授权,开放统计信息就可以由 Smartglass 以及 iOS、Android、Windows、Windows Phone 和 Web 应用程序访问。用户对沙盒的授权通过 Partner Center 管理。

以下示例是该检查的伪代码:

```cpp theme={null}
If (!checkAccess(serviceConfigId, resource, CLAIM[userid, deviceid, titleid]))
{
        Reject request as Unauthorized
}

// else accept request.
         
```

## 必需的请求标头

| 标头 | 类型 | 说明 |
| - | - | - |
| Authorization | string | 用于 HTTP 身份验证的凭据。示例值:"XBL3.0 x=\<userhash>;\<token>"。 |

## 可选的请求标头

\| 标头 | 类型 | 说明 |
\| --- | --- | --- | --- | --- | --- |
\| X-RequestedServiceVersion |  | 此请求应发送到的服务的生成名称/编号。仅在验证标头的有效性、认证令牌中的声明等之后,请求才会被路由到该服务。默认值:1。 |

## 请求正文

### 请求示例

下面的 POST 正文通知服务:正在为两个不同的用户从两个不同的 SCID 请求四个统计信息。

```cpp theme={null}
{    
"requestedusers": [
                1234567890123460,
                1234567890123234
            ],
            "requestedscids": [
                {
                    "scid": "c402ff50-3e76-11e2-a25f-0800200c1212",
                    "requestedstats": [
                        "Test4FirefightKills",
                        "Test4FirefightHeadshots"
                    ]
                },
                {
                    "scid": "c402ff50-3e76-11e2-a25f-0800200c0343",
                    "requestedstats": [
                        "OverallTestKills",
                        "TestHeadshots"
                    ]
                }
            ] 
}
      
```

## HTTP 状态代码

服务针对使用此方法对此资源发出的请求,返回本节中的某个状态代码。有关与 XBOX Live 服务一同使用的标准 HTTP 状态代码的完整列表,请参见 [标准 HTTP 状态代码](https://devdocs.xbox.com/zh-CN/reference/live/rest/additional/httpstatuscodes)。

\| 代码 | 原因短语 | 说明 |
\| --- | --- | --- | --- | --- | --- | --- | --- | --- |
\| 200 | OK | 已成功检索会话。 |
\| 304 | Not Modified | 自上次请求以来资源未被修改。 |
\| 400 | Bad Request | 服务无法理解格式错误的请求。通常是无效参数。 |
\| 401 | Unauthorized | 请求需要用户身份验证。 |
\| 403 | Forbidden | 不允许该用户或服务发出请求。 |
\| 404 | Not Found | 找不到指定的资源。 |
\| 406 | Not Acceptable | 不支持资源版本。 |
\| 408 | Request Timeout | 不支持资源版本;应由 MVC 层拒绝。 |

## 响应正文

### 响应示例

```cpp theme={null}
{    
   "users":[          
       {    
	  "xuid": "123456789"
        "gamertag": "WarriorSaint",
        "scids":[
          {
             "scid":"c402ff50-3e76-11e2-a25f-0800200c1212",
             "stats":  [
		  {
		         "statname":"Test4FirefightKills",
		         "type":"Integer",
		         "value":7
             },
		  {
		         "statname":"Test4FirefightHeadshots",
		         "type":"Integer",
		         "value":4
             }]
                        },
          {
             "scid":"c402ff50-3e76-11e2-a25f-0800200c0343",
             "stats":  [
		  {
		         "statname":"OverallTestKills",
		         "type":"Integer",
		         "value":3434
             },
		  {
		         "statname":"TestHeadshots",
		         "type":"Integer",
		         "value":41
             }]
          }],
                   },
    {    
                   "gamertag":"TigerShark",
                   "xuid":1234567890123234
        "scids":[
          {
             "scid":"123456789",
             "stats":  [
		  {
		         "statname":"Test4FirefightKills",
		         "type":"Integer",
		         "value":63
             },
		  {
		         "statname":"Test4FirefightHeadshots",
		         "type":"Integer",
		         "value":12
             }]
                        },
          {
"scid":"987654321",
             "stats":  [
		  {
		         "statname":"OverallTestKills",
		         "type":"Integer",
		         "value":375
             },
		  {
		         "statname":"TestHeadshots",
		         "type":"Integer",
		         "value":34
             }]
          }],
                   }]
}
         
```

## 另请参阅

##### 父主题

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


## Related topics

- [XblUserStatisticsGetMultipleUserStatisticsAsync](https://devdocs.xbox.com/reference/live/xsapi-c/user_statistics_c/functions/xbluserstatisticsgetmultipleuserstatisticsasync.md)
- [XblUserStatisticsGetMultipleUserStatisticsForMultipleServiceConfigurationsAsync](https://devdocs.xbox.com/reference/live/xsapi-c/user_statistics_c/functions/xbluserstatisticsgetmultipleuserstatisticsformultipleserviceconfigurationsasync.md)
