since we're doing this in two methods, might be worth having an internal encode_data method or something that does the base64 and json encoding.