创建

描述

object httptest.create(object/array webScenarios)

此方法允许创建新的Web场景。

创建一个Web场景将自动创建一组web monitoring items

此方法只有Admin(管理员)Super admin(超级管理员) 用户可用。可以在用户角色设置中撤销调用该方法的权限。更多信息请查看 User roles

参数

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

除了 standard web scenario properties,此方法接受如下参数。

参数 类型 描述
steps
(必填)
array Web场景steps
tags array Web场景tags

返回值

(object) 返回一个包含已创建Web场景ID的对象,ID在httptestids属性下。返回的IDs的顺序和传递的Web场景的顺序相匹配。

示例

创建一个Web场景

创建一个Web场景用于监控公司主页。此场景具有两个步骤,检查主页和“关于”页,并保证它们返回HTTP状态码200。

请求:

{
    "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
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}

响应:

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

参见

来源

CHttpTest::create() in ui/include/classes/api/services/CHttpTest.php.