In den folgenden Beispielen werden mehrere häufige Anforderungen beschrieben, darunter Authentifizierung, Geräte- und Aufgabenerstellung, Abrufen einer Liste von Plattformen und Abrufen von Geräteinformationen mithilfe von Postman (siehe auch Die Verwendung von Postman für Auslastungstests).

Um mit der Dotcom-Monitor-API zu beginnen, muss der HTTP/HTTPS-Header Content-Type auf application/jsonfestgelegt haben.

Die Details zur API-Methode finden Sie im entsprechenden Artikel aus der Kategorie Methoden.

einloggen

Verwenden Sie für die Authentifizierung den POST-URI „/login„. Wenn Sie sich über den Anruf „/login“ anmelden, beginnt eine neue Clientsitzung. Sitzungen laufen automatisch nach einer vorgegebenen Dauer der Inaktivität ab. Der Standardwert ist eine Minute. Wenn Sie einen API-Aufruf durchführen, wird der Inaktivitätszeitgeber auf Null zurückgesetzt.

Wenn Ihre Sitzung abläuft, wird der HTTP-Ausnahmefehlercode““401 – Unauthorized“ zurückgegeben. In diesem Fall müssen Sie sich erneut anmelden.

Es wird empfohlen, Ihre Integrations-UID für die Anmeldung zu verwenden (Konto Integration > > UID).

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
POST /config_api_v1/login HTTP/1.1
Host: api.dotcom-monitor.com
Content-Type: application/json
{
"UID":"0E206D45650A4ACD8EB689B8CC25FA7F"
}
POST /config_api_v1/login HTTP/1.1 Host: api.dotcom-monitor.com Content-Type: application/json { "UID":"0E206D45650A4ACD8EB689B8CC25FA7F" }
POST /config_api_v1/login HTTP/1.1
Host: api.dotcom-monitor.com
Content-Type: application/json

{ 
"UID":"0E206D45650A4ACD8EB689B8CC25FA7F"
}

Get Platforms

Um die Liste der Überwachungsplattformen abzudateien, verwenden Sie GET URI „
/platforms
. Wenn die Anforderung erfolgreich ist, antwortet der Server mit einem HTTP-Statuscode und der Liste aller verfügbaren Plattformen. Es wird empfohlen, die Antwort zu speichern, um Ihre Kontodaten (Paket-ID, Plattform-ID, Geräte-ID usw.) in nachfolgenden Anforderungen zu verwenden.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
GET /config_api_v1/platforms HTTP/1.1
Host: api.dotcom-monitor.com
Content-Type: application/json
GET /config_api_v1/platforms HTTP/1.1 Host: api.dotcom-monitor.com Content-Type: application/json
GET /config_api_v1/platforms HTTP/1.1
Host: api.dotcom-monitor.com
Content-Type: application/json

Erstellen eines Geräts

Verwenden Sie die in der Antwort „GET-Plattformen“ empfangenen Daten, um eine JSON-Anforderung zu erstellen. Die Geräteparameter, die nicht in der Anforderung angegeben sind, werden auf Standard festgelegt.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
POST /config_api_v1/devices?verb=PUT HTTP/1.1
Host: api.dotcom-monitor.com
Content-Type: application/json
{
"Postpone":"true",
"Frequency":60,
"Package_Id":465,
"Platform_Id":12,
"Locations":{2,4,6,18,68},
"Name":"TESTDEVICE 9.23.2019"
}
POST /config_api_v1/devices?verb=PUT HTTP/1.1 Host: api.dotcom-monitor.com Content-Type: application/json { "Postpone":"true", "Frequency":60, "Package_Id":465, "Platform_Id":12, "Locations":{2,4,6,18,68}, "Name":"TESTDEVICE 9.23.2019" }
POST /config_api_v1/devices?verb=PUT HTTP/1.1
Host: api.dotcom-monitor.com
Content-Type: application/json

{ 
"Postpone":"true",
"Frequency":60,
"Package_Id":465,
"Platform_Id":12,
"Locations":{2,4,6,18,68},
"Name":"TESTDEVICE 9.23.2019"
}

Erstellen einer Aufgabe

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Post /config_api_v1/tasks?verb=PUT HTTP/1.1
Host: api.dotcom-monitor.com
Content-Type: application/json
{
"Name":"testname",
"Url":"https://dotcom-monitor.com",
"Device_Id":123456,
"RequestType":"GET",
"Task_Type_Id":2,
"DNSResolveMode":"Device Cached"
}
Post /config_api_v1/tasks?verb=PUT HTTP/1.1 Host: api.dotcom-monitor.com Content-Type: application/json { "Name":"testname", "Url":"https://dotcom-monitor.com", "Device_Id":123456, "RequestType":"GET", "Task_Type_Id":2, "DNSResolveMode":"Device Cached" }
Post /config_api_v1/tasks?verb=PUT HTTP/1.1
Host: api.dotcom-monitor.com
Content-Type: application/json

{
"Name":"testname",
"Url":"https://dotcom-monitor.com",
"Device_Id":123456,
"RequestType":"GET",
"Task_Type_Id":2,
"DNSResolveMode":"Device Cached"
}

Abrufen und Bearbeiten von Geräteinformationen

Um Geräteinformationen zu bearbeiten, senden Sie zunächst eine GET-Anforderung mit der Geräte-ID im URI, um die Serverantwort zu empfangen.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
GET /config_api_v1//device/193403 HTTP/1.1
Host: api.dotcom-monitor.com
Content-Type: application/json
GET /config_api_v1//device/193403 HTTP/1.1 Host: api.dotcom-monitor.com Content-Type: application/json
GET /config_api_v1//device/193403 HTTP/1.1
Host: api.dotcom-monitor.com
Content-Type: application/json

Verwenden Sie als Nächstes den Antworttext, um Geräteparameter zu ändern und die JSON-Anforderung mit neuen Werten zurückzusenden.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
POST /config_api_v1//device/193403 HTTP/1.1
Host: api.dotcom-monitor.com
Content-Type: application/json
{
"Avoid_Simultaneous_Checks": false,
"Alert_Silence_Min": 0,
"False_Positive_Check": false,
"Locations": [
1,
2,
3,
4,
6,
11,
13,
14,
15,
18,
19,
23,
43,
68,
97,
113,
118,
138,
153,
233
],
"Send_Uptime_Alert": false,
"Status_Description": "POSTPONED",
"Postpone": true,
"Owner_Device_Id": 0,
"Frequency": 10800,
"Filter_Id": 7791,
"Scheduler_Id": 0,
"Notifications": {
"E_Mail_Flag": false,
"E_Mail_Address": null,
"E_Mail_TimeInterval_Min": 5,
"WL_Device_Flag": false,
"WL_Device_Email_Address": null,
"WL_Device_TimeInterval_Min": 15,
"Pager_Flag": false,
"Pager_Area_Code": null,
"Pager_Phone": null,
"Pager_Num_Code": null,
"Pager_TimeInterval_Min": 15,
"Phone_Flag": false,
"Phone_Area_Code": null,
"Phone_Phone": null,
"Phone_TimeInterval_Min": 15,
"SMS_Flag": false,
"SMS_Phone": null,
"SMS_TimeInterval_Min": 15,
"Script_Flag": false,
"Script_Batch_File_Name": null,
"Script_TimeInterval_Min": 0,
"SNMP_TimeInterval_Min": 0,
"Notification_Groups": []
},
"Id": 193403,
"Number_Of_Tasks": 1,
"WaitingForApproval": false,
"Platform_Id": 12,
"Package_Id": 465,
"Name": "Under_Task"
}
POST /config_api_v1//device/193403 HTTP/1.1 Host: api.dotcom-monitor.com Content-Type: application/json { "Avoid_Simultaneous_Checks": false, "Alert_Silence_Min": 0, "False_Positive_Check": false, "Locations": [ 1, 2, 3, 4, 6, 11, 13, 14, 15, 18, 19, 23, 43, 68, 97, 113, 118, 138, 153, 233 ], "Send_Uptime_Alert": false, "Status_Description": "POSTPONED", "Postpone": true, "Owner_Device_Id": 0, "Frequency": 10800, "Filter_Id": 7791, "Scheduler_Id": 0, "Notifications": { "E_Mail_Flag": false, "E_Mail_Address": null, "E_Mail_TimeInterval_Min": 5, "WL_Device_Flag": false, "WL_Device_Email_Address": null, "WL_Device_TimeInterval_Min": 15, "Pager_Flag": false, "Pager_Area_Code": null, "Pager_Phone": null, "Pager_Num_Code": null, "Pager_TimeInterval_Min": 15, "Phone_Flag": false, "Phone_Area_Code": null, "Phone_Phone": null, "Phone_TimeInterval_Min": 15, "SMS_Flag": false, "SMS_Phone": null, "SMS_TimeInterval_Min": 15, "Script_Flag": false, "Script_Batch_File_Name": null, "Script_TimeInterval_Min": 0, "SNMP_TimeInterval_Min": 0, "Notification_Groups": [] }, "Id": 193403, "Number_Of_Tasks": 1, "WaitingForApproval": false, "Platform_Id": 12, "Package_Id": 465, "Name": "Under_Task" }
POST /config_api_v1//device/193403 HTTP/1.1
Host: api.dotcom-monitor.com
Content-Type: application/json

{
    "Avoid_Simultaneous_Checks": false,
    "Alert_Silence_Min": 0,
    "False_Positive_Check": false,
    "Locations": [
        1,
        2,
        3,
        4,
        6,
        11,
        13,
        14,
        15,
        18,
        19,
        23,
        43,
        68,
        97,
        113,
        118,
        138,
        153,
        233
    ],
    "Send_Uptime_Alert": false,
    "Status_Description": "POSTPONED",
    "Postpone": true,
    "Owner_Device_Id": 0,
    "Frequency": 10800,
    "Filter_Id": 7791,
    "Scheduler_Id": 0,
    "Notifications": {
        "E_Mail_Flag": false,
        "E_Mail_Address": null,
        "E_Mail_TimeInterval_Min": 5,
        "WL_Device_Flag": false,
        "WL_Device_Email_Address": null,
        "WL_Device_TimeInterval_Min": 15,
        "Pager_Flag": false,
        "Pager_Area_Code": null,
        "Pager_Phone": null,
        "Pager_Num_Code": null,
        "Pager_TimeInterval_Min": 15,
        "Phone_Flag": false,
        "Phone_Area_Code": null,
        "Phone_Phone": null,
        "Phone_TimeInterval_Min": 15,
        "SMS_Flag": false,
        "SMS_Phone": null,
        "SMS_TimeInterval_Min": 15,
        "Script_Flag": false,
        "Script_Batch_File_Name": null,
        "Script_TimeInterval_Min": 0,
        "SNMP_TimeInterval_Min": 0,
        "Notification_Groups": []
    },
    "Id": 193403,
    "Number_Of_Tasks": 1,
    "WaitingForApproval": false,
    "Platform_Id": 12,
    "Package_Id": 465,
    "Name": "Under_Task"
}

Weitere Informationen zum Erstellen von Geräten mit Dotcom-Monitor-APIs finden Sie in unserem Wiki.