[comment]: # translation:outdated

[comment]: # ({3c277f74-3c277f74})
# httptest.create

[comment]: # ({/3c277f74-3c277f74})

[comment]: # ({9408d3d8-c4bddb28})
### 描述

`object httptest.create(object/array webScenarios)`

此方法用于 create 新的 Web 场景。

::: noteclassic
创建 Web 场景将自动为该场景 create
一组 [web monitoring items](/manual/web_monitoring/items)。
:::

::: noteclassic
此方法仅对 *Admin（管理员）* 和 *Super admin（超级管理员）*
用户类型可用。调用该方法的权限可以在用户角色设置中撤销。更多信息，请参见 [User
roles](/manual/web_interface/frontend_sections/users/user_roles)。
:::

[comment]: # ({/9408d3d8-c4bddb28})

[comment]: # ({d8705e6a-5bd5a38b})
### 参数

`(object/array)` 要创建的 Web 场景。

除了 [web-场景](object#web-场景) 外，该方法还接受以下参数。

| 参数 | [数据类型](/manual/api/reference_commentary#数据类型) | 描述 |
|--|--|------|
| steps | array | [场景步骤](/manual/api/reference/httptest/object#场景步骤)。<br><br>[参数行为](/manual/api/reference_commentary#参数行为)：<br>- *必填* |
| tags | array | [web-场景标签](/manual/api/reference/httptest/object#web-场景标签)。 |

[comment]: # ({/d8705e6a-5bd5a38b})

[comment]: # ({0f4da548-0f4da548})
### 返回值

`(object)` 返回一个 object，其中包含在 `httptestids` 属性下列出的已创建 Web 场景的 ID。返回的 ID 顺序与传入的 Web 场景顺序一致。

[comment]: # ({/0f4da548-0f4da548})

[comment]: # ({b41637d2-b41637d2})
### 示例

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({5125d2fe-0b10bb11})
#### 创建 Web 场景

创建一个Web场景以监控公司主页。该场景将包含两个步骤，用于检查主页和“关于”页面，并确保它们返回HTTP状态码200。

[执行请求](/manual/api#执行请求):


```json
{
    "jsonrpc": "2.0",
    "method": "httptest.create",
    "params": {
        "name": "Homepage check",
        "hostid": "10085",
        "steps": [
            {
                "name": "Homepage",
                "url": "http://example.com",
                "status_codes": "200",
                "no": 1
            },
            {
                "name": "Homepage / About",
                "url": "http://example.com/about",
                "status_codes": "200",
                "no": 2
            }
        ]
    },
    "id": 1
}
```
响应：


```json
{
    "jsonrpc": "2.0",
    "result": {
        "httptestids": [
            "5"
        ]
    },
    "id": 1
}
```

[comment]: # ({/5125d2fe-0b10bb11})

[comment]: # ({e8ca015f-e8ca015f})
### 另请参阅

-   [场景步骤](object#场景步骤)

[comment]: # ({/e8ca015f-e8ca015f})

[comment]: # ({6b938292-6b938292})
### 来源

CHttpTest::create() 在 *ui/include/classes/api/services/CHttpTest.php* 中。

[comment]: # ({/6b938292-6b938292})
