Spaces:
Sleeping
Sleeping
File size: 4,003 Bytes
7466735 |
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
"""
Diagnose the actual API response structure
"""
import requests
import json
API_URL = "https://aadarshsenapati.in/api/api.php"
print("=" * 70)
print("RAW API RESPONSE DIAGNOSTIC")
print("=" * 70)
# Test 1: Get parking lots
print("\n1. GET PARKING LOTS")
print("-" * 70)
response = requests.get(f"{API_URL}?action=get_parking_lots", timeout=10)
print(f"Status Code: {response.status_code}")
print(f"\nRaw Response Text:")
print(response.text)
print(f"\nParsed JSON:")
data = response.json()
print(json.dumps(data, indent=2))
if data.get('status') == 'success' and data.get('data'):
print(f"\nπ First Record Fields:")
first_record = data['data'][0]
for key, value in first_record.items():
print(f" {key}: {value} (type: {type(value).__name__})")
# Test 2: Get users (if endpoint exists)
print("\n\n2. GET USERS")
print("-" * 70)
try:
response = requests.get(f"{API_URL}?action=get_users", timeout=10)
print(f"Status Code: {response.status_code}")
if response.status_code == 200:
print(json.dumps(response.json(), indent=2))
except Exception as e:
print(f"Error: {e}")
# Test 3: Get slots (if different from lots)
print("\n\n3. GET SLOTS")
print("-" * 70)
try:
response = requests.get(f"{API_URL}?action=get_slots", timeout=10)
print(f"Status Code: {response.status_code}")
if response.status_code == 200:
data = response.json()
print(json.dumps(data, indent=2))
if data.get('status') == 'success' and data.get('data'):
print(f"\nπ First Slot Record Fields:")
first_record = data['data'][0]
for key, value in first_record.items():
print(f" {key}: {value} (type: {type(value).__name__})")
except Exception as e:
print(f"Error: {e}")
# Test 4: Get slots by lot_id
print("\n\n4. GET SLOTS BY LOT ID")
print("-" * 70)
try:
response = requests.get(f"{API_URL}?action=get_slots_by_lot&lot_id=1", timeout=10)
print(f"Status Code: {response.status_code}")
if response.status_code == 200:
data = response.json()
print(json.dumps(data, indent=2))
if data.get('status') == 'success' and data.get('data'):
print(f"\nπ First Slot Record Fields:")
first_record = data['data'][0]
for key, value in first_record.items():
print(f" {key}: {value} (type: {type(value).__name__})")
except Exception as e:
print(f"Error: {e}")
# Test 5: Get available slots
print("\n\n5. GET AVAILABLE SLOTS")
print("-" * 70)
try:
response = requests.get(f"{API_URL}?action=get_available_slots", timeout=10)
print(f"Status Code: {response.status_code}")
if response.status_code == 200:
data = response.json()
print(json.dumps(data, indent=2))
if data.get('status') == 'success' and data.get('data'):
print(f"\nπ First Slot Record Fields:")
first_record = data['data'][0]
for key, value in first_record.items():
print(f" {key}: {value} (type: {type(value).__name__})")
except Exception as e:
print(f"Error: {e}")
# Test 6: Try to get parking_slots table data
print("\n\n6. GET PARKING SLOTS (alternative endpoint name)")
print("-" * 70)
try:
response = requests.get(f"{API_URL}?action=get_parking_slots", timeout=10)
print(f"Status Code: {response.status_code}")
if response.status_code == 200:
data = response.json()
print(json.dumps(data, indent=2))
if data.get('status') == 'success' and data.get('data'):
print(f"\nπ First Slot Record Fields:")
first_record = data['data'][0]
for key, value in first_record.items():
print(f" {key}: {value} (type: {type(value).__name__})")
except Exception as e:
print(f"Error: {e}")
print("\n" + "=" * 70)
print("END DIAGNOSTIC")
print("=" * 70)
|