fix error checking

check for null, remove api key, return response if now encoded string