import urllib.request import json url = "https://iam.ultramodul.xyz/api/auth/login" data = json.dumps({"email": "tsm@tsm.id", "password": "wrong"}).encode("utf-8") req = urllib.request.Request(url, data=data, headers={"Content-Type": "application/json"}, method="POST") try: with urllib.request.urlopen(req) as f: print(f.read().decode('utf-8')) except Exception as e: print(e) if hasattr(e, 'read'): print(e.read().decode('utf-8'))