import sys import os import requests from dotenv import load_dotenv # Explicitly load .env from the project root dotenv_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '.env')) load_dotenv(dotenv_path=dotenv_path, override=True) sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from superoffice_client import SuperOfficeClient def get_raw_data(contact_id: int): print(f"🚀 Fetching RAW response for ContactId: {contact_id}") try: client = SuperOfficeClient() if not client.access_token: print("❌ Authentication failed.") return # Build URL manually to avoid any JSON parsing in the client url = f"{client.base_url}/Contact/{contact_id}?$select=Name,UserDefinedFields" headers = client.headers print(f"URL: {url}") resp = requests.get(url, headers=headers) print(f"Status Code: {resp.status_code}") # Save raw content to a file output_file = "raw_api_response.json" with open(output_file, "w") as f: f.write(resp.text) print(f"✅ Raw response saved to {output_file}") print("\nFirst 500 characters of response:") print(resp.text[:500]) except Exception as e: print(f"❌ Error: {e}") if __name__ == "__main__": get_raw_data(171185)