REST API for todo context is awkward
Migrated from the original issue at https://www.assembla.com/spaces/tracks-tickets/tickets/1224
A request like this will only work is 'newcontextcomputer' is actually a new context:
<todo>
<description>task 1 in 11111111, 11111</description>
<project_id>31</project_id>
<notes>my notes here</notes>
<tags>
<tag><name>starred</name></tag>
<tag><name>blue</name></tag></tags>
<context><name>newcontextcomputer</name></context>
</todo>
This is awkward, because to use the REST API properly, one has to follow this:
- Check if context already exists.
- If context exists, then get context_id and use <context_id>#id</context_id>
- If context doesn't exist, then use
#name
To improve usability, the following should be the two options for defining a context in a call:
<context><name>#new_or_existing_name</name></context>
<context><id>#existing_id_only</id></context>
Originally reported by popsch on November 11, 2011 at 11:35:13 (-0600) against version git-devel
On November 11, 2011 at 11:39:41 (-0600), popsch commented:
Btw. if currently use
ActiveRecord::StatementInvalid in TodosController#create
SQLite3::ConstraintException: todos.context_id may not be NULL: INSERT INTO "todos" ("context_id", "completed_at", "recurring_todo_id", "created_at", "show_from", "project_id", "notes", "updated_at", "user_id", "description", "due", "state") VALUES(NULL, NULL, NULL, '2011-11-20 17:37:17', NULL, 31, 'my notes here', '2011-11-20 17:37:17', 1, 'task 1 in 11111111, 11111', NULL, 'active')
On November 11, 2011 at 20:19:42 (-0600), popsch commented:
Also, I think a similar thing is true for the project and project_id.
On November 11, 2011 at 08:25:17 (-0600), lrbalt commented:
(In [[r:50bc2623d9f3925c3351fd5d3fd3ac6102114804]]) fix #1224. Allow existing and non-existing project/context names in REST API
Branch: master
On November 11, 2011 at 08:26:42 (-0600), lrbalt commented:
should work now, see the examples in the todo_xml test in the commit.
On November 11, 2011 at 09:20:51 (-0600), popsch commented:
part way there. I was also suggesting to deprecate
<projcet_id>#id</project_id> in favour of
and deprecate <context_id>#id</context_id> in favour of
On November 11, 2011 at 13:11:01 (-0600), lrbalt commented:
perhaps later, that will require extra logic.
On November 11, 2011 at 14:39:06 (-0600), popsch commented:
Then let's leave this open and move it to a later milestone.
On November 11, 2011 at 14:40:03 (-0600), popsch commented:
Btw. what happens now if you use <context_id> and
On November 11, 2011 at 04:07:21 (-0600), lrbalt commented:
only one way to find out :-)