Added BadResponseException to allow catching of 'not ok' responses. Fixed bug in api generation.