From d6245fd6bac6206e55d04e869413b8bf50cc9883 Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Sat, 27 Sep 2014 18:34:23 +1000 Subject: [PATCH] Correctly set error code for missing SNMP version --- html/includes/api_functions.inc.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/html/includes/api_functions.inc.php b/html/includes/api_functions.inc.php index bd48ad54f..fe0a3c5cd 100644 --- a/html/includes/api_functions.inc.php +++ b/html/includes/api_functions.inc.php @@ -326,6 +326,7 @@ function list_devices() function add_device() { // This will add a device using the data passed encoded with json + // FIXME: Execution flow through this function could be improved global $config; $app = \Slim\Slim::getInstance(); $data = json_decode(file_get_contents('php://input'), true); @@ -368,15 +369,17 @@ function add_device() } else { + $code = 400; + $status = "error"; $message = "You haven't specified an SNMP version to use"; } - $code = 201; if(empty($message)) { require_once("../includes/functions.php"); $result = addHost($hostname, $snmpver, $port, $transport, 1); if($result) { + $code = 201; $status = "ok"; $message = "Device $hostname has been added successfully"; }