59 lines
No EOL
1.7 KiB
Python
59 lines
No EOL
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Debug Unipile API response to understand the issue.
|
|
"""
|
|
import os
|
|
import httpx
|
|
import json
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
api_key = os.getenv('UNIPILE_API_KEY')
|
|
account_id = os.getenv('UNIPILE_ACCOUNT_ID')
|
|
|
|
print(f"API Key: {api_key[:20] if api_key else 'NOT SET'}")
|
|
print(f"Account ID: {account_id}")
|
|
|
|
# Test with a simple known profile
|
|
test_url = f"https://api1.unipile.com:13111/api/v1/linkedin/profile/giovannafossati"
|
|
headers = {
|
|
"X-API-KEY": api_key,
|
|
"accept": "application/json"
|
|
}
|
|
|
|
print(f"\nTesting URL: {test_url}")
|
|
print(f"Headers: {json.dumps(headers, indent=2)}")
|
|
|
|
try:
|
|
with httpx.Client(timeout=30.0) as client:
|
|
response = client.get(test_url, headers=headers)
|
|
print(f"\nStatus Code: {response.status_code}")
|
|
print(f"Response Headers: {dict(response.headers)}")
|
|
|
|
if response.status_code == 200:
|
|
data = response.json()
|
|
print(f"\nSuccess! Profile data:")
|
|
print(json.dumps(data, indent=2))
|
|
else:
|
|
print(f"\nError Response:")
|
|
print(response.text)
|
|
|
|
except Exception as e:
|
|
print(f"\nException: {e}")
|
|
|
|
# Also test account status
|
|
account_url = f"https://api1.unipile.com:13111/api/v1/accounts/{account_id}"
|
|
print(f"\n\nTesting account status: {account_url}")
|
|
|
|
try:
|
|
with httpx.Client(timeout=30.0) as client:
|
|
response = client.get(account_url, headers=headers)
|
|
print(f"\nAccount Status: {response.status_code}")
|
|
if response.status_code == 200:
|
|
data = response.json()
|
|
print(f"Account Info: {json.dumps(data, indent=2)}")
|
|
else:
|
|
print(f"Account Error: {response.text}")
|
|
except Exception as e:
|
|
print(f"Account Exception: {e}") |