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
for cookie in cookie_jar:
print("Cookie:", cookie.name, "=", cookie.value[:80] if len(cookie.value) > 80 else cookie.value)
# Now try creating a cron job - make sure cookie is sent
payload = json.dumps({"prompt": "Test prompt", "schedule": "every 30m", "name": "Test Job", "deliver": ["local"]}).encode()
req = urllib.request.Request("http://127.0.0.1:5100/api/claude-jobs", data=payload, headers={"Content-Type": "application/json"}, method="POST")
# Debug: print the cookie that will be sent
cookie_header = ""
for cookie in cookie_jar:
if cookie.domain in ["127.0.0.1", "localhost"] or cookie.domain == "":
cookie_header += f"{cookie.name}={cookie.value}; "
print("Cookie header to be sent:", cookie_header)
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)