I'm writing a python script (Can't use the python sdk because the server I'm using is not configured for Python 3) that calls the PlayFab reset password api. I am purposely calling the api with a bogus token and password so that I can test my error handling code. When I run the script using my computer as a local host it works fine and Playfab returns an error json as expected. When I test the api call in Postman using the same parameters it also works fine. But when I upload the script to the actual google cloud server it's supposed to run on, the content of the response I get back from Playfab is a garbled mess and can't be json decoded:
u'E\\ufffdK\\n\\ufffd@\\x10\\ufffd\\ufffd4\\ufffd\\x0e\\ufffd\\ufffd\\x10\\ufffd\\ufffd\\ufffdR\\x17\\ufffd\\x0b\\x0cNa\\ufffd0m\\ufffd{@\\x10\\ufffd\\ufffd$\\x04\\ufffd\\ufffd\\ufffd\\ufffd\\ufffd\\ufffd\\x10\\x0f\\ufffd\\ufffdeY\\ufffd\\ufffd\\ufffd\\ufffd\\ufffd\\ufffd\\ufffd\\ufffd;\\ufffd\\x045.\\x181J\\ufffd\\ufffd!\\ufffd\\ufffd\\ufffd\\x0b\\ufffd,\\u041b\\ufffd\\ufffd3n\\ufffdiQ\\ufffd\\ufffdn\\ufffd\\ufffd\\nU\\ufffd\\ufffd2\\ufffd\\x03\\ufffd\\u63aa\\ufffd\\ufffd\\ufffdS\\ufffd\\ufffd1\\ufffd\\ufffd\\x0c\\x051\\ufffd\\x0c\\ufffd\\ufffd\\ufffd\\x07'
This the code as I originally wrote it:
parameters = {'Password':password,'Token':token} headers = {'Content-Type': 'application/json','X-SecretKey':secretKey} playFabResponse = requests.post(url = apiUrl, json = parameters,headers = headers try: json = playFabResponse.json() response = flask.jsonify(json) except: #I get a json parsing exception on google cloud only
This is the current state of my code. I've experimented with several ways of calling the post function and have tried adding many different headers, and nothing I've tried works.
parameters = dumps({'Password':password,'Token':token}) headers = {'Content-Type': 'application/json','Accept-Encoding':'gzip, deflate','X-SecretKey':secretKey,'X-ReportErrorAsSuccess':'true','X-PlayFabSDK':'PythonSdk-0.0.190410'} playFabResponse = requests.post(apiUrl,data = parameters,headers = headers)
I've also tried these:
playFabResponse.encoding = 'utf-8' playFabResponse.encoding = 'ascii'
And this:
#throws an exception on google cloud only responseWrapper = json.loads(playFabResponse.content.decode("utf-8"))
I printed out a good response and a bad response and I analyzed the diff and there are a few notable differences:
Good: playFabResponse.apparent_encoding = 'ascii'
Bad: playFabResponse.apparent_encoding = 'ISO-8859-8'
Good: playFabResponse.headers = {'content-encoding': 'deflate' ...
Bad: 'content-encoding' is missing from headers
I'm not sure if this is an issue with my google cloud configuration, the way I'm calling the post function and reading the response, or if this is an issue on the PlayFab side. I've been stuck on this for many hours now and I'd appreciate some fresh ideas. Thanks.