BZ-1074989 - REST API returns HTTP code 500 (compilation fix and cleanup)

(cherry picked from commit a202740de9f3bab207ce6a3801aa694fd5a5ce83)