-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_smartlists_api.py
More file actions
69 lines (59 loc) · 2.69 KB
/
Copy pathtest_smartlists_api.py
File metadata and controls
69 lines (59 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from src.api.formstack_client import FormstackClient
def test_smartlists_api():
"""Test SmartLists API endpoints to understand the issue"""
try:
client = FormstackClient()
print("Testing SmartLists API endpoints...")
print("=" * 50)
# Test different SmartList endpoints
endpoints_to_try = [
"smartlist",
"smartlists",
"smartlist.json",
"smartlists.json"
]
for endpoint in endpoints_to_try:
print(f"\n--- Testing endpoint: {endpoint} ---")
try:
response = client._make_request("GET", endpoint)
print(f"✅ Success! Response type: {type(response)}")
print(f"Response: {response}")
if isinstance(response, dict):
print(f"Keys: {list(response.keys())}")
if 'smartlists' in response:
smartlists = response['smartlists']
print(f"SmartLists count: {len(smartlists)}")
if smartlists:
print(f"First SmartList: {smartlists[0]}")
elif isinstance(response, list):
print(f"Direct list length: {len(response)}")
if response:
print(f"First item: {response[0]}")
except Exception as e:
print(f"❌ Failed: {e}")
# Test if SmartLists are available in account
print(f"\n--- Testing account capabilities ---")
try:
# Check if we can get any account info that mentions smartlists
endpoints_to_check = ["account", "account.json", "user/account"]
for endpoint in endpoints_to_check:
try:
response = client._make_request("GET", endpoint)
print(f"✅ {endpoint} success: {type(response)}")
if isinstance(response, dict):
# Look for smartlist-related keys
for key in response.keys():
if 'smart' in key.lower() or 'list' in key.lower():
print(f" Found key: {key} = {response[key]}")
except Exception as e:
print(f"❌ {endpoint} failed: {e}")
except Exception as e:
print(f"Account check failed: {e}")
except Exception as e:
print(f"Error during SmartLists API test: {e}")
if __name__ == "__main__":
test_smartlists_api()