The issue here is that updateFile expects a unicode string while encode_json returns a binary string unlike to_json.