Chilkat Online Tools

Unicode C++ / Datadog API Collection / Create an API test

Back to Collection Items

void ChilkatSample(void)
    {
    json.UpdateString(L"config.assertions[0].operator",L"lessThan");    json.UpdateInt(L"config.assertions[0].target",1000);    json.UpdateString(L"config.assertions[0].type",L"responseTime");    json.UpdateString(L"config.assertions[1].operator",L"is");    json.UpdateInt(L"config.assertions[1].target",200);    json.UpdateString(L"config.assertions[1].type",L"statusCode");    json.UpdateString(L"config.assertions[2].operator",L"is");    json.UpdateString(L"config.assertions[2].property",L"content-type");    json.UpdateString(L"config.assertions[2].target",L"text/html; charset=UTF-8");    json.UpdateString(L"config.assertions[2].type",L"header");    json.UpdateString(L"config.request.method",L"GET");    json.UpdateString(L"config.request.url",L"https://example.com");    json.UpdateString(L"locations[0]",L"azure:eastus");    json.UpdateString(L"locations[1]",L"aws:eu-west-3");    json.UpdateString(L"message",L"MY_NOTIFICATION_MESSAGE");    json.UpdateString(L"name",L"MY_TEST_NAME");    json.UpdateInt(L"options.min_failure_duration",0);    json.UpdateInt(L"options.min_location_failed",1);    json.UpdateBool(L"options.monitor_options.include_tags",true);    json.UpdateBool(L"options.monitor_options.locked",false);    json.UpdateInt(L"options.monitor_options.new_host_delay",300);    json.UpdateBool(L"options.monitor_options.notify_audit",false);    json.UpdateBool(L"options.monitor_options.notify_no_data",false);    json.UpdateInt(L"options.monitor_options.renotify_interval",0);    json.UpdateInt(L"options.tick_every",60);    json.UpdateString(L"status",L"live");    json.UpdateString(L"subtype",L"http");    json.UpdateString(L"tags[0]",L"env:production");    json.UpdateString(L"type",L"api");    resp->GetBodySb(sbResponseBody);    jResp.LoadSb(sbResponseBody);    jResp.put_EmitCompact(false);    jResp.put_I(i);    operator = jResp.stringOf(L"config.assertions[i].operator");    target = jResp.IntOf(L"config.assertions[i].target");    v_type = jResp.stringOf(L"config.assertions[i].type");    i = i + 1;    i = 0;    count_i = jResp.SizeOfArray(L"locations");    jResp.put_I(i);    strVal = jResp.stringOf(L"locations[i]");    i = i + 1;    i = 0;    count_i = jResp.SizeOfArray(L"options.device_ids");    jResp.put_I(i);    strVal = jResp.stringOf(L"options.device_ids[i]");    i = i + 1;    i = 0;    count_i = jResp.SizeOfArray(L"options.restricted_roles");    jResp.put_I(i);    strVal = jResp.stringOf(L"options.restricted_roles[i]");    i = i + 1;    i = 0;    count_i = jResp.SizeOfArray(L"options.scheduling.timeframes");    jResp.put_I(i);    day = jResp.IntOf(L"options.scheduling.timeframes[i].day");    from = jResp.stringOf(L"options.scheduling.timeframes[i].from");    v_to = jResp.stringOf(L"options.scheduling.timeframes[i].to");    i = i + 1;    i = 0;    count_i = jResp.SizeOfArray(L"tags");    jResp.put_I(i);    strVal = jResp.stringOf(L"tags[i]");    i = i + 1;
    }

Curl Command

curl -X POST
	-H "Content-Type: application/json"
	-H "Accept: application/json"
	-d '{
  "config": {
    "assertions": [
      {
        "operator": "lessThan",
        "target": 1000,
        "type": "responseTime"
      },
      {
        "operator": "is",
        "target": 200,
        "type": "statusCode"
      },
      {
        "operator": "is",
        "property": "content-type",
        "target": "text/html; charset=UTF-8",
        "type": "header"
      }
    ],
    "request": {
      "method": "GET",
      "url": "https://example.com"
    }
  },
  "locations": [
    "azure:eastus",
    "aws:eu-west-3"
  ],
  "message": "MY_NOTIFICATION_MESSAGE",
  "name": "MY_TEST_NAME",
  "options": {
    "min_failure_duration": 0,
    "min_location_failed": 1,
    "monitor_options": {
      "include_tags": true,
      "locked": false,
      "new_host_delay": 300,
      "notify_audit": false,
      "notify_no_data": false,
      "renotify_interval": 0
    },
    "tick_every": 60
  },
  "status": "live",
  "subtype": "http",
  "tags": [
    "env:production"
  ],
  "type": "api"
}'
https://api.app.ddog-gov.com/api/v1/synthetics/tests/api

Postman Collection Item JSON

{
  "name": "Create an API test",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"config\": {\n    \"assertions\": [\n      {\n        \"operator\": \"lessThan\",\n        \"target\": 1000,\n        \"type\": \"responseTime\"\n      },\n      {\n        \"operator\": \"is\",\n        \"target\": 200,\n        \"type\": \"statusCode\"\n      },\n      {\n        \"operator\": \"is\",\n        \"property\": \"content-type\",\n        \"target\": \"text/html; charset=UTF-8\",\n        \"type\": \"header\"\n      }\n    ],\n    \"request\": {\n      \"method\": \"GET\",\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"locations\": [\n    \"azure:eastus\",\n    \"aws:eu-west-3\"\n  ],\n  \"message\": \"MY_NOTIFICATION_MESSAGE\",\n  \"name\": \"MY_TEST_NAME\",\n  \"options\": {\n    \"min_failure_duration\": 0,\n    \"min_location_failed\": 1,\n    \"monitor_options\": {\n      \"include_tags\": true,\n      \"locked\": false,\n      \"new_host_delay\": 300,\n      \"notify_audit\": false,\n      \"notify_no_data\": false,\n      \"renotify_interval\": 0\n    },\n    \"tick_every\": 60\n  },\n  \"status\": \"live\",\n  \"subtype\": \"http\",\n  \"tags\": [\n    \"env:production\"\n  ],\n  \"type\": \"api\"\n}",
      "options": {
        "raw": {
          "headerFamily": "json",
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{baseUrl}}/api/v1/synthetics/tests/api",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "synthetics",
        "tests",
        "api"
      ]
    },
    "description": "Create a Synthetic API test."
  },
  "response": [
    {
      "name": "OK - Returns the created test details.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"config\": {\n    \"assertions\": [\n      {\n        \"operator\": \"lessThan\",\n        \"target\": 1000,\n        \"type\": \"responseTime\"\n      },\n      {\n        \"operator\": \"is\",\n        \"target\": 200,\n        \"type\": \"statusCode\"\n      },\n      {\n        \"operator\": \"is\",\n        \"property\": \"content-type\",\n        \"target\": \"text/html; charset=UTF-8\",\n        \"type\": \"header\"\n      }\n    ],\n    \"request\": {\n      \"method\": \"GET\",\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"locations\": [\n    \"azure:eastus\",\n    \"aws:eu-west-3\"\n  ],\n  \"message\": \"MY_NOTIFICATION_MESSAGE\",\n  \"name\": \"MY_TEST_NAME\",\n  \"options\": {\n    \"min_failure_duration\": 0,\n    \"min_location_failed\": 1,\n    \"monitor_options\": {\n      \"include_tags\": true,\n      \"locked\": false,\n      \"new_host_delay\": 300,\n      \"notify_audit\": false,\n      \"notify_no_data\": false,\n      \"renotify_interval\": 0\n    },\n    \"tick_every\": 60\n  },\n  \"status\": \"live\",\n  \"subtype\": \"http\",\n  \"tags\": [\n    \"env:production\"\n  ],\n  \"type\": \"api\"\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/synthetics/tests/api",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "synthetics",
            "tests",
            "api"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"name\": \"Example test name\",\n  \"config\": {\n    \"assertions\": [\n      {\n        \"operator\": \"lessThan\",\n        \"target\": 1000,\n        \"type\": \"responseTime\"\n      }\n    ],\n    \"request\": {\n      \"method\": \"GET\",\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"locations\": [\n    \"aws:eu-west-3\"\n  ],\n  \"options\": {\n    \"accept_self_signed\": true,\n    \"allow_insecure\": true,\n    \"checkCertificateRevocation\": true,\n    \"ci\": {\n      \"executionRule\": \"non_blocking\"\n    },\n    \"device_ids\": [\n      \"laptop_large\",\n      \"laptop_large\"\n    ],\n    \"disableCors\": false,\n    \"disableCsp\": false,\n    \"follow_redirects\": true,\n    \"httpVersion\": \"http1\",\n    \"ignoreServerCertificateError\": false,\n    \"initialNavigationTimeout\": 87780679,\n    \"min_failure_duration\": -32472759,\n    \"min_location_failed\": -5806955,\n    \"monitor_name\": \"et deserunt \",\n    \"monitor_options\": {\n      \"renotify_interval\": 834\n    },\n    \"monitor_priority\": 3,\n    \"noScreenshot\": false,\n    \"restricted_roles\": [\n      \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"\n    ],\n    \"retry\": {\n      \"count\": -50657150,\n      \"interval\": -91565669.0691471\n    },\n    \"rumSettings\": {\n      \"applicationId\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\",\n      \"clientTokenId\": 12345,\n      \"isEnabled\": true\n    },\n    \"scheduling\": {\n      \"timeframes\": [\n        {\n          \"day\": 1,\n          \"from\": \"07:00\",\n          \"to\": \"16:00\"\n        },\n        {\n          \"day\": 3,\n          \"from\": \"07:00\",\n          \"to\": \"16:00\"\n        }\n      ],\n      \"timezone\": \"America/New_York\"\n    },\n    \"tick_every\": 384020\n  },\n  \"type\": \"api\",\n  \"message\": \"Notification message\",\n  \"monitor_id\": 12345678,\n  \"public_id\": \"123-abc-456\",\n  \"status\": \"live\",\n  \"subtype\": \"http\",\n  \"tags\": [\n    \"env:production\"\n  ]\n}"
    },
    {
      "name": "- JSON format is wrong\n- Creation failed",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"config\": {\n    \"assertions\": [\n      {\n        \"operator\": \"lessThan\",\n        \"target\": 1000,\n        \"type\": \"responseTime\"\n      },\n      {\n        \"operator\": \"is\",\n        \"target\": 200,\n        \"type\": \"statusCode\"\n      },\n      {\n        \"operator\": \"is\",\n        \"property\": \"content-type\",\n        \"target\": \"text/html; charset=UTF-8\",\n        \"type\": \"header\"\n      }\n    ],\n    \"request\": {\n      \"method\": \"GET\",\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"locations\": [\n    \"azure:eastus\",\n    \"aws:eu-west-3\"\n  ],\n  \"message\": \"MY_NOTIFICATION_MESSAGE\",\n  \"name\": \"MY_TEST_NAME\",\n  \"options\": {\n    \"min_failure_duration\": 0,\n    \"min_location_failed\": 1,\n    \"monitor_options\": {\n      \"include_tags\": true,\n      \"locked\": false,\n      \"new_host_delay\": 300,\n      \"notify_audit\": false,\n      \"notify_no_data\": false,\n      \"renotify_interval\": 0\n    },\n    \"tick_every\": 60\n  },\n  \"status\": \"live\",\n  \"subtype\": \"http\",\n  \"tags\": [\n    \"env:production\"\n  ],\n  \"type\": \"api\"\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/synthetics/tests/api",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "synthetics",
            "tests",
            "api"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\n  ]\n}"
    },
    {
      "name": "Test quota is reached",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"config\": {\n    \"assertions\": [\n      {\n        \"operator\": \"lessThan\",\n        \"target\": 1000,\n        \"type\": \"responseTime\"\n      },\n      {\n        \"operator\": \"is\",\n        \"target\": 200,\n        \"type\": \"statusCode\"\n      },\n      {\n        \"operator\": \"is\",\n        \"property\": \"content-type\",\n        \"target\": \"text/html; charset=UTF-8\",\n        \"type\": \"header\"\n      }\n    ],\n    \"request\": {\n      \"method\": \"GET\",\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"locations\": [\n    \"azure:eastus\",\n    \"aws:eu-west-3\"\n  ],\n  \"message\": \"MY_NOTIFICATION_MESSAGE\",\n  \"name\": \"MY_TEST_NAME\",\n  \"options\": {\n    \"min_failure_duration\": 0,\n    \"min_location_failed\": 1,\n    \"monitor_options\": {\n      \"include_tags\": true,\n      \"locked\": false,\n      \"new_host_delay\": 300,\n      \"notify_audit\": false,\n      \"notify_no_data\": false,\n      \"renotify_interval\": 0\n    },\n    \"tick_every\": 60\n  },\n  \"status\": \"live\",\n  \"subtype\": \"http\",\n  \"tags\": [\n    \"env:production\"\n  ],\n  \"type\": \"api\"\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/synthetics/tests/api",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "synthetics",
            "tests",
            "api"
          ]
        }
      },
      "status": "Payment Required",
      "code": 402,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\n  ]\n}"
    },
    {
      "name": "Forbidden",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"config\": {\n    \"assertions\": [\n      {\n        \"operator\": \"lessThan\",\n        \"target\": 1000,\n        \"type\": \"responseTime\"\n      },\n      {\n        \"operator\": \"is\",\n        \"target\": 200,\n        \"type\": \"statusCode\"\n      },\n      {\n        \"operator\": \"is\",\n        \"property\": \"content-type\",\n        \"target\": \"text/html; charset=UTF-8\",\n        \"type\": \"header\"\n      }\n    ],\n    \"request\": {\n      \"method\": \"GET\",\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"locations\": [\n    \"azure:eastus\",\n    \"aws:eu-west-3\"\n  ],\n  \"message\": \"MY_NOTIFICATION_MESSAGE\",\n  \"name\": \"MY_TEST_NAME\",\n  \"options\": {\n    \"min_failure_duration\": 0,\n    \"min_location_failed\": 1,\n    \"monitor_options\": {\n      \"include_tags\": true,\n      \"locked\": false,\n      \"new_host_delay\": 300,\n      \"notify_audit\": false,\n      \"notify_no_data\": false,\n      \"renotify_interval\": 0\n    },\n    \"tick_every\": 60\n  },\n  \"status\": \"live\",\n  \"subtype\": \"http\",\n  \"tags\": [\n    \"env:production\"\n  ],\n  \"type\": \"api\"\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/synthetics/tests/api",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "synthetics",
            "tests",
            "api"
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\n  ]\n}"
    },
    {
      "name": "Too many requests",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"config\": {\n    \"assertions\": [\n      {\n        \"operator\": \"lessThan\",\n        \"target\": 1000,\n        \"type\": \"responseTime\"\n      },\n      {\n        \"operator\": \"is\",\n        \"target\": 200,\n        \"type\": \"statusCode\"\n      },\n      {\n        \"operator\": \"is\",\n        \"property\": \"content-type\",\n        \"target\": \"text/html; charset=UTF-8\",\n        \"type\": \"header\"\n      }\n    ],\n    \"request\": {\n      \"method\": \"GET\",\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"locations\": [\n    \"azure:eastus\",\n    \"aws:eu-west-3\"\n  ],\n  \"message\": \"MY_NOTIFICATION_MESSAGE\",\n  \"name\": \"MY_TEST_NAME\",\n  \"options\": {\n    \"min_failure_duration\": 0,\n    \"min_location_failed\": 1,\n    \"monitor_options\": {\n      \"include_tags\": true,\n      \"locked\": false,\n      \"new_host_delay\": 300,\n      \"notify_audit\": false,\n      \"notify_no_data\": false,\n      \"renotify_interval\": 0\n    },\n    \"tick_every\": 60\n  },\n  \"status\": \"live\",\n  \"subtype\": \"http\",\n  \"tags\": [\n    \"env:production\"\n  ],\n  \"type\": \"api\"\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/synthetics/tests/api",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "synthetics",
            "tests",
            "api"
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\n  ]\n}"
    }
  ]
}