mytinytodo
mytinytodo copied to clipboard
Add a new task via curl
Add a new task via curl e.g.
curl http://myhost/add?list=personal?task="My new task"
As for now you can use
curl \
--data-urlencode "list=1" \
--data-urlencode "title=/+1/ Task with spaces /Tag1, Tag2/" \
"http://localhost/mytinytodo/ajax.php?newTask"
This command will add a task to list with ID = 1: title: Task with spaces priority: +1 tags: Tag1, Tag2
Settings: v1.6.x. No password is set. Smart syntax is enabled.
This works great! Thank you.
I'm going to comment on this one as it's related.
Is it possible to add an automatic refresh option when a new task is added via curl or simply on a timer?
Context: I'm scripting the addition of tasks when something happens on my servers that I need to attend to and I have MyTinyTodo on my status page now. This would allow me to see critical (Prio +2) issues asap and respond to them.
Hello, can you help me understand how to interact with API?
I wanna post new tasks via curl, but as I understand, I need to authenticate, because without it I always get response 403 when I post to .../api.php?_path=/lists with mtt-token, which I get from .../api.php?_path=/session
{
"total": 0,
"list": [],
"denied": 1
}
So, first I make POST to .../api.php?_path=/session and get mtt-token
Next I make POST to .../api.php?_path=/login with header mtt-token *** and JsonBody with my password password *** but always get response 200
{
"logged": 0
}
Thank you!
In v1.7 http api was changed.
- Get session id and token for login:
curl -X POST "test:8080/api.php?_path=/session"
returns
{
"session": "rhon8fisk5dj4pmtc9hrbeddge",
"token": "4d4d8110-1fd6-42f3-a507-eea46d24512a"
}
- Login with password as well as token and session id from step 1. You'll get new token for further requests. Session id will be the same.
curl "test:8080/api.php?_path=/login" \
--header "Content-Type: application/json" \
--header "MTT-Token: 4d4d8110-1fd6-42f3-a507-eea46d24512a" \
--header "Cookie: mtt-session=rhon8fisk5dj4pmtc9hrbeddge" \
--data '{"password":"foo"}'
returns
{
"logged": 1,
"token": "6e72c91f-99e4-4968-b6f6-72161441b9c7"
}
- Create task. Pass token from step 2 and session id from step 1.
curl "test:8080/api.php?_path=/tasks" \
--header "Content-Type: application/json" \
--header "MTT-Token: 6e72c91f-99e4-4968-b6f6-72161441b9c7" \
--header "Cookie: mtt-session=rhon8fisk5dj4pmtc9hrbeddge" \
--data '{"list":44, "title":"+1 Task with spaces #Tag1 #Tag2"}'
returns
{
"total": 1,
"list": [...]
}
}
Thank you for help!
@maxpozdeev Did the API change for 1.8? When I try:
curl -X POST "https://my.domain.com/api.php?_path=/session"
it returns:
{"disabled":1}%
No password is set and Smart Syntax is enabled.
@s22-tech No API changed in 1.8. You need to set password.
O.K. That makes the api work. However, I don't want to have to login when I access the site via the browser. Is there a way to have the password only affect the api?
Without password you don't need to call "/session" and "/login" api endpoints.
Just do request with some random identifier passed in MTT-Token header and mtt-token cookie (both the same).
curl "test:8080/api.php?_path=/tasks" \
--header "Content-Type: application/json" \
--header "MTT-Token: some-string" \
--header "Cookie: mtt-token=some-string" \
--data '{"list":44, "title":"+1 Task with spaces #Tag1 #Tag2 @monday"}'