Testing check mk API in Postman

What you used is not the REST api. It is the “old” webapi.
Here is a very brief example Postman collection with a “get all hosts” request.

{
	"info": {
		"name": "CMK Rest API",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"item": [
		{
			"name": "Get all Hosts",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					}
				],
				"url": {
					"raw": "http://monitoringhost/sitename/check_mk/api/1.0/domain-types/host_config/collections/all",
					"protocol": "http",
					"host": [
						"monitoringhost",
					],
					"path": [
						"sitename",
						"check_mk",
						"api",
						"1.0",
						"domain-types",
						"host_config",
						"collections",
						"all"
					]
				}
			},
			"response": []
		}
	],
	"auth": {
		"type": "bearer",
		"bearer": [
			{
				"key": "token",
				"value": "automation automationsecret",
				"type": "string"
			}
		]
	},
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		}
	]
}

Documentation an REST api gui can be found here.
image

1 Like