client = Client(api_key_testnet, sec_key_testnet,testnet=True)... 502 Bad Gateway.

I just started doing automation in Python.client = Client(api_key_testnet, sec_key_testnet,testnet=True) worked fine, but now in response: ApiError(code=0): Invalid JSON error message from Binance: 502 Bad Gateway. I tried it on a non-test server, it works fine.

It seems that it caused by testnet monthly reset. Please retry soon later. It should work after the maintenance is finished.