创建

说明

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

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

创建Web场景将自动创建一组web监控项.

参数

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

除了 标准Web场景属性之外, 该方法接受以下参数

参数类型说明
steps
(required)
arrayWeb方案步骤。

返回值

(object)返回一个包含“httptestids”属性下创建的Web场景的ID的对象。 返回的ID的顺序与传递的Web方案的顺序相匹配。

示例

创建Web场景

创建一个Web场景来监视公司主页。 该方案将有两个步骤,以检查主页和“关于”页面,并确保它们返回HTTP状态代码200。

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "httptest.create",
  4. "params": {
  5. "name": "Homepage check",
  6. "hostid": "10085",
  7. "steps": [
  8. {
  9. "name": "Homepage",
  10. "url": "http://mycompany.com",
  11. "status_codes": "200",
  12. "no": 1
  13. },
  14. {
  15. "name": "Homepage / About",
  16. "url": "http://mycompany.com/about",
  17. "status_codes": "200",
  18. "no": 2
  19. }
  20. ]
  21. },
  22. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  23. "id": 1
  24. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "httptestids": [
  5. "5"
  6. ]
  7. },
  8. "id": 1
  9. }

参见

来源

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