[comment]: # translation:outdated

[comment]: # ({7f8cd3a3-7f8cd3a3})
# httptest.get

[comment]: # ({/7f8cd3a3-7f8cd3a3})

[comment]: # ({70e0f3e6-96cbc36d})
### 描述

`integer/array httptest.get(object parameters)`

该方法允许根据给定参数检索Web场景

::: noteclassic
该方法适用于所有类型的用户。调用该方法的权限可以在用户角色设置中撤销。更多信息请参见[User
roles](/manual/web_interface/frontend_sections/users/user_roles)

:::

[comment]: # ({/70e0f3e6-96cbc36d})

[comment]: # ({fcb60d36-7be2c19f})
### 参数

`(object)` 定义期望输出的参数。

该方法支持以下参数。

| 参数 | [数据类型](/manual/api/reference_commentary#数据类型) | 描述 |
|--|--|------|
| groupids | ID/array | 仅返回属于指定主机组的Web场景。 |
| hostids | ID/array | 仅返回属于指定主机的Web场景。 |
| httptestids | ID/array | 仅返回具有指定ID的Web场景。 |
| inherited | boolean | 如果设置为`true`，则仅返回从模板继承的Web场景。 |
| monitored | boolean | 如果设置为`true`，则仅返回属于受监控主机的已启用Web场景。 |
| templated | boolean | 如果设置为`true`，则仅返回属于模板的Web场景。 |
| templateids | ID/array | 仅返回属于指定模板的Web场景。 |
| expandName | flag | 在Web场景名称中展开宏。 |
| expandStepName | flag | 在场景步骤名称中展开宏。 |
| evaltype | integer | 标签搜索规则。<br><br>可能的值：<br>0 - (默认) 与/或；<br>2 - 或。 |
| tags | array | 仅返回具有指定标签的Web场景。根据操作符值，对标签进行精确匹配或对标签值进行大小写敏感/不敏感的搜索。<br>格式：`[{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...]`。<br>空array返回所有Web场景。<br><br>可能的操作符类型：<br>0 - (默认) 类似；<br>1 - 等于；<br>2 - 不类似；<br>3 - 不等于；<br>4 - 存在；<br>5 - 不存在。 |
| selectHosts | query | 将Web场景所属的主机作为[`hosts`](/manual/api/reference/host/object)属性中的array返回。 |
| selectSteps | query | 在[`steps`](/manual/api/reference/httptest/object#scenario_step)属性中返回Web场景步骤。<br><br>支持`count`。 |
| selectTags | query | 在[`tags`](/manual/api/reference/httptest/object#web_scenario_tag)属性中返回Web场景标签。 |
| sortfield | string/array | 按给定属性对结果进行排序。<br><br>可能的值：`httptestid`，`name`。 |
| countOutput | boolean | 这些参数在[通用get方法参数](/manual/api/reference_commentary#通用get方法参数)中有描述。 |
| editable | boolean | ^           |
| excludeSearch | boolean | ^           |
| filter | object | ^           |
| limit | integer | ^           |
| output | query | ^           |
| preservekeys | boolean | ^           |
| search | object | ^           |
| searchByAny | boolean | ^           |
| searchWildcardsEnabled | boolean | ^           |
| sortorder | string/array | ^           |
| startSearch | boolean | ^           |

[comment]: # ({/fcb60d36-7be2c19f})

[comment]: # ({07ca11ca-7223bab1})
### 返回值

`(integer/array)` 返回以下两种结果之一:

-   一个包含array的objects数组;
-   检索到的objects数量, 如果使用了`countOutput`参数。

[comment]: # ({/07ca11ca-7223bab1})

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

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

[comment]: # ({300b343b-c93618d6})
#### 获取 Web 场景

获取Web场景"4"的所有数据

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

```json
{
    "jsonrpc": "2.0",
    "method": "httptest.get",
    "params": {
        "output": "extend",
        "selectSteps": "extend",
        "httptestids": "9"
    },
    "id": 1
}
```
响应:

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "httptestid": "9",
            "name": "Homepage check",
            "delay": "1m",
            "status": "0",
            "variables": [],
            "agent": "Zabbix",
            "authentication": "0",
            "http_user": "",
            "http_password": "",
            "hostid": "10084",
            "templateid": "0",
            "http_proxy": "",
            "retries": "1",
            "ssl_cert_file": "",
            "ssl_key_file": "",
            "ssl_key_password": "",
            "verify_peer": "0",
            "verify_host": "0",
            "headers": [],
            "steps": [
                {
                    "httpstepid": "36",
                    "httptestid": "9",
                    "name": "Homepage",
                    "no": "1",
                    "url": "http://example.com",
                    "timeout": "15s",
                    "posts": "",
                    "required": "",
                    "status_codes": "200",
                    "variables": [
                        {
                            "name":"{var}",
                            "value":"12"
                        }
                    ],
                    "follow_redirects": "1",
                    "retrieve_mode": "0",
                    "headers": [],
                    "query_fields": []
                },
                {
                    "httpstepid": "37",
                    "httptestid": "9",
                    "name": "Homepage / About",
                    "no": "2",
                    "url": "http://example.com/about",
                    "timeout": "15s",
                    "posts": "",
                    "required": "",
                    "status_codes": "200",
                    "variables": [],
                    "follow_redirects": "1",
                    "retrieve_mode": "0",
                    "headers": [],
                    "query_fields": []
                }
            ]
        }
    ],
    "id": 1
}
```

[comment]: # ({/300b343b-c93618d6})

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

-   [主机](/manual/api/reference/host/object#主机)
-   [场景步骤](object#场景步骤)

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

[comment]: # ({8ec619ff-8ec619ff})
### 来源

CHttpTest::get() 位于 *ui/include/classes/api/services/CHttpTest.php* 文件中。

[comment]: # ({/8ec619ff-8ec619ff})
