Chilkat Online Tools

Foxpro / MongoDB Atlas / Get Open Alerts for Alert Configuration

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loResp

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

loHttp = CreateObject('Chilkat_9_5_0.Http')

loHttp.DigestAuth = 1
loHttp.Login = "username"
loHttp.Password = "password"

* Use this online tool to generate code from sample JSON: Generate Code to Create JSON

* The following JSON is sent in the request body.

* {
*   "enabled": false
* }

loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateBool("enabled",0)

loHttp.SetRequestHeader("Content-Type","application/json")

loSbRequestBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loJson.EmitSb(loSbRequestBody)

loResp = loHttp.PTextSb("GET","https://domain.com/api/atlas/{{version}}/groups/{{ProjectID}}/alertConfigs/{{ALERT-CONFIG-ID}}/alerts",loSbRequestBody,"utf-8","application/json",0,0)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loJson
    RELEASE loSbRequestBody
    CANCEL
ENDIF

? STR(loResp.StatusCode)
? loResp.BodyStr
RELEASE loResp

RELEASE loHttp
RELEASE loJson
RELEASE loSbRequestBody

Curl Command

curl -X GET
	--digest -u 'username:password'
	-H "Content-Type: application/json"
	-d '{
    "enabled": false
}'
https://domain.com/api/atlas/{{version}}/groups/{{ProjectID}}/alertConfigs/{{ALERT-CONFIG-ID}}/alerts

Postman Collection Item JSON

{
  "name": "Get Open Alerts for Alert Configuration",
  "protocolProfileBehavior": {
    "disableBodyPruning": true
  },
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"enabled\": false\n}"
    },
    "url": {
      "raw": "{{base_url}}/api/atlas/{{version}}/groups/{{ProjectID}}/alertConfigs/{{ALERT-CONFIG-ID}}/alerts",
      "host": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "atlas",
        "{{version}}",
        "groups",
        "{{ProjectID}}",
        "alertConfigs",
        "{{ALERT-CONFIG-ID}}",
        "alerts"
      ]
    },
    "description": "https://docs.atlas.mongodb.com/reference/api/alert-configurations-get-open-alerts/"
  },
  "response": [
  ]
}