[CNS] fix api.lua to correctly report "HTTP/1.1 500 Internal Server Error" (#299)