I'm trying to create a scheduled task through API and I get this response:
Failed to create cron job: 403 {"detail":"You do not have permission to perform this action."}
NOTE: I HAVE A FREE ACCOUNT
Code responsible for that result:
async def cron_command(user_id, time):
enter code here
api_url = "https://www.pythonanywhere.com/api/v0/user/*****/schedule/"
api_key = "*********"
command = f"python3 /home/*******/*****/******/tasks.py {user_id}"
time_obj = datetime.strptime(time, "%H:%M")
hour = time_obj.hour
minute = time_obj.minute
data = {
"enabled": True,
"command": command,
"hour": hour,
"minute": minute,
"interval": "daily"}
headers = {
"Authorization": f"Token {api_key}",
"Content-Type": "application/json"
}
response = requests.post(api_url, headers=headers, data=json.dumps(data))
if response.status_code == 201:
print("Cron job created successfully.")
else:
print(f"Failed to create cron job: {response.status_code}")
print(response.text)