Check in refactoring of Devices API to support proper JSON Error
handling