From 2015635d224db35d51eaaf122ca1f1f43e7e38b7 Mon Sep 17 00:00:00 2001 From: int2001 Date: Sun, 29 Dec 2024 09:20:40 +0000 Subject: [PATCH 1/2] If there was an error at inserting QSO via API, return information and 400 --- application/controllers/Api.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/application/controllers/Api.php b/application/controllers/Api.php index 3e496f9ae..fcdb2a7e5 100644 --- a/application/controllers/Api.php +++ b/application/controllers/Api.php @@ -234,8 +234,15 @@ class API extends CI_Controller { $return_msg[]='Dryrun works'; } - http_response_code(201); - echo json_encode(['status' => 'created', 'type' => $obj['type'], 'string' => $obj['string'], 'adif_count' => $adif_count, 'adif_errors' => $adif_errors, 'messages' => $return_msg ]); + if ($adif_errors == 0) { + http_response_code(201); + echo json_encode(['status' => 'created', 'type' => $obj['type'], 'string' => $obj['string'], 'adif_count' => $adif_count, 'adif_errors' => $adif_errors, 'messages' => $return_msg ]); + } else { + $return_msg[]=$custom_errors; + http_response_code(400); + echo json_encode(['status' => 'created', 'type' => $obj['type'], 'string' => $obj['string'], 'adif_count' => $adif_count, 'adif_errors' => $adif_errors, 'messages' => $return_msg ]); + } + } From 58402a3b050efde18ef071634191bb97d546b22e Mon Sep 17 00:00:00 2001 From: int2001 Date: Sun, 29 Dec 2024 09:22:26 +0000 Subject: [PATCH 2/2] aborted instead of created --- application/controllers/Api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/Api.php b/application/controllers/Api.php index fcdb2a7e5..75831b8f7 100644 --- a/application/controllers/Api.php +++ b/application/controllers/Api.php @@ -240,7 +240,7 @@ class API extends CI_Controller { } else { $return_msg[]=$custom_errors; http_response_code(400); - echo json_encode(['status' => 'created', 'type' => $obj['type'], 'string' => $obj['string'], 'adif_count' => $adif_count, 'adif_errors' => $adif_errors, 'messages' => $return_msg ]); + echo json_encode(['status' => 'abort', 'type' => $obj['type'], 'string' => $obj['string'], 'adif_count' => $adif_count, 'adif_errors' => $adif_errors, 'messages' => $return_msg ]); }