import urllib.request, json, urllib.error, http.cookiejar
cookie_jar = http.cookiejar.CookieJar()
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cookie_jar))
# Try the login endpoint - it's /api/auth not /api/auth/login
login_data = json.dumps({"password": "ASM-vps00#"}).encode()
req = urllib.request.Request("http://127.0.0.1:5100/api/auth", data=login_data, headers={"Content-Type": "application/json"}, method="POST")
try:
with opener.open(req, timeout=10) as r:
print("login:", r.status)
print(r.read().decode())
except urllib.error.HTTPError as e:
print("login error:", e.code, e.read().decode())
except Exception as e:
print("login error:", e)
# Check cookies in detail
for cookie in cookie_jar:
print("Cookie:", cookie.name, "=", cookie.value[:80] if len(cookie.value) > 80 else cookie.value)
print(" domain:", cookie.domain)
print(" path:", cookie.path)
print(" secure:", cookie.secure)
# Now try creating a cron job with explicit cookie header
# deliver should be a string, not array
payload = json.dumps({"prompt": "Test prompt", "schedule": "every 30m", "name": "Test Job", "deliver": "local"}).encode()
# Build cookie header manually
cookie_parts = []
for cookie in cookie_jar:
cookie_parts.append(f"{cookie.name}={cookie.value}")
cookie_header = "; ".join(cookie_parts)
print("Cookie header:", cookie_header)
req = urllib.request.Request("http://127.0.0.1:5100/api/claude-jobs", data=payload, headers={"Content-Type": "application/json", "Cookie": cookie_header}, method="POST")
try:
with opener.open(req, timeout=30) as r:
print("create job:", r.status)
print(r.read().decode())
except urllib.error.HTTPError as e:
print("create job error:", e.code, e.read().decode())
except Exception as e:
print("create job error:", e)