]> granicus.if.org Git - icinga2/commitdiff
Add global API parameters to the docs; Add API troubleshooting section 6205/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Thu, 12 Apr 2018 17:44:58 +0000 (19:44 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Thu, 12 Apr 2018 17:44:58 +0000 (19:44 +0200)
doc/12-icinga2-api.md
doc/15-troubleshooting.md

index 48d96e6993a406922f4f26eb9d9b666923bb81b1..c05522999fd3aa6c0387a3a816aaa86b34a9eaa8 100644 (file)
@@ -103,7 +103,7 @@ The output will be sent back as a JSON object:
 
 > **Tip**
 >
-> You can use the `pretty` parameter to beautify the JSON response with Icinga v2.9+.
+> You can use the [pretty](12-icinga2-api.md#icinga2-api-parameters-global) parameter to beautify the JSON response with Icinga v2.9+.
 
 You can also use [jq](https://stedolan.github.io/jq/) or `python -m json.tool`
 in combination with curl on the CLI.
@@ -272,6 +272,27 @@ Here are the exact same query parameters as a JSON object:
 The [match function](18-library-reference.md#global-functions-match) is available as global function
 in Icinga 2.
 
+### Global Parameters <a id="icinga2-api-parameters-global"></a>
+
+Name            | Description
+----------------|--------------------
+pretty          | Pretty-print the JSON response.
+verbose         | Add verbose debug information inside the `diagnostic_information` key into the response if available. This helps with troubleshooting failing requests.
+
+Example as URL parameter:
+
+```
+/v1/objects/hosts?pretty=1
+```
+
+Example as JSON object:
+
+```
+{ "pretty": true }
+```
+
+Both parameters have been added in Icinga 2 v2.9.
+
 ### Request Method Override <a id="icinga2-api-requests-method-override"></a>
 
 `GET` requests do not allow you to send a request body. In case you cannot pass everything as URL
index c0fad94f612b93eb4c28b4bd67d348ce36f348cd..8e1fc63ff5329d86b5a5829199c1a13d71cb3717 100644 (file)
@@ -702,6 +702,33 @@ Look into the log and check whether the feature logs anything specific for this
 grep GraphiteWriter /var/log/icinga2/icinga2.log
 ```
 
+## REST API Troubleshooting <a id="troubleshooting-api"></a>
+
+In order to analyse errors on API requests, you can explicitly enable the [verbose parameter](12-icinga2-api.md#icinga2-api-parameters-global).
+
+```
+$ curl -k -s -u root:icinga -H 'Accept: application/json' -X DELETE 'https://localhost:5665/v1/objects/hosts/example-cmdb?pretty=1&verbose=1'
+{
+    "diagnostic_information": "Error: Object does not exist.\n\n ....",
+    "error": 404.0,
+    "status": "No objects found."
+}
+```
+
+## REST API Troubleshooting: No Objects Found <a id="troubleshooting-api-no-objects-found"></a>
+
+Please note that the `404` status with no objects being found can also originate
+from missing or too strict object permissions for the authenticated user.
+
+This is a security feature to disable object name guessing. If this would not be the
+case, restricted users would be able to get a list of names of your objects just by
+trying every character combination.
+
+In order to analyse and fix the problem, please check the following:
+
+- use an administrative account with full permissions to check whether the objects are actually there.
+- verify the permissions on the affected ApiUser object and fix them.
+
 
 ## Certificate Troubleshooting <a id="troubleshooting-certificate"></a>