Sample Create Webdriver API script
search cancel

Sample Create Webdriver API script

book

Article ID: 280159

calendar_today

Updated On: 03-12-2024

Products

CA App Synthetic Monitor

Issue/Introduction

Please send a sample request that uses the Webdriver script? We found the schema for webdriver create monitor but we are unclear how to craft our request . So a sample web driver request will be very useful.

Resolution

There are many options which are described in the schemas. Some are required but most of them are optional. Below is an example of a very bare request. You may want to change the folder ID and contact ID but the nulls are perfectly fine.

 

{
  "name": "Example",
  "folderId": null,
  "check": {
    "interval": "00:05:00"
  },
  "alert": {
    "timeWarn": 5000,
    "timePoor": 10000,
    "timeOut": 30,
    "contactId": null,
    "notifyWhenUp": true
  },
  "checkpoint": {
    "usePublic": true,
    "algorithm": "random"
  },
  "type": "webdriver",
  "scriptFile": {
    "contentArchive": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestCase><selenese><command>open</command><target><![CDATA[https://<target_url>]]></target><value></value></selenese></TestCase>"
  },
  "browser": "chrome"
}

Additional Information

This is only the json content. The full request can be performed using e.g. curl in this way:

curl -X 'POST' -k \
  'https://api.asm.saas.broadcom.com/v3/monitors' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <bearer>' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Example",
  "folderId": null,
  "check": {
    "interval": "00:05:00"
  },
  "alert": {
    "timeWarn": 5000,
    "timePoor": 10000,
    "timeOut": 30,
    "contactId": null,
    "notifyWhenUp": true
  },
  "checkpoint": {
    "usePublic": true,
    "algorithm": "random"
  },
  "type": "webdriver",
  "scriptFile": {
    "contentArchive": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestCase><selenese><command>open</command><target><![CDATA[https://<url>]]></target><value></value></selenese></TestCase>"
  },
  "browser": "chrome"
}'