From 822f9eb854f6d4fcda3d22bd0f4705b4a587ddd5 Mon Sep 17 00:00:00 2001 From: emkael Date: Sun, 20 Jan 2019 12:51:45 +0100 Subject: Ensuring JSON output on error, setting Content-Type --- http/api.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'http/api.php') diff --git a/http/api.php b/http/api.php index ab8d002..e83420b 100644 --- a/http/api.php +++ b/http/api.php @@ -193,11 +193,11 @@ function run($parameters) { } catch (ParametersException $e) { http_response_code(400); - die($e->getMessage()); + die(json_encode($e->getMessage())); } catch (Exception $e) { http_response_code(500); - die($e->getMessage()); + die(json_encode($e->getMessage())); } } @@ -205,6 +205,7 @@ function run($parameters) { http_response_code(405); die('API only accepts POST requests'); } else {*/ + header('Content-Type: application/json'); print(json_encode(run($_REQUEST))); //} -- cgit v1.2.3