Merge pull request #1407 from int2001/api_error

If there was an error at inserting QSO via API, return 400
This commit is contained in:
Joerg (DJ7NT)
2024-12-31 18:05:55 +01:00
committed by GitHub

View File

@@ -243,8 +243,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' => 'abort', 'type' => $obj['type'], 'string' => $obj['string'], 'adif_count' => $adif_count, 'adif_errors' => $adif_errors, 'messages' => $return_msg ]);
}
}