tracks icon indicating copy to clipboard operation
tracks copied to clipboard

REST API for todo context is awkward

Open dnrce opened this issue 11 years ago • 9 comments

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:

  1. Check if context already exists.
  2. If context exists, then get context_id and use <context_id>#id</context_id>
  3. 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

dnrce avatar Jun 25 '14 16:06 dnrce

On November 11, 2011 at 11:39:41 (-0600), popsch commented:

Btw. if currently use #name with an existing context, then you will get the following error message:

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')

dnrce avatar Jun 25 '14 16:06 dnrce

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.

dnrce avatar Jun 25 '14 16:06 dnrce

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

dnrce avatar Jun 25 '14 16:06 dnrce

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.

dnrce avatar Jun 25 '14 16:06 dnrce

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

#id to go along with the other method #name

and deprecate <context_id>#id</context_id> in favour of

#id to go along with the other method #name

dnrce avatar Jun 25 '14 16:06 dnrce

On November 11, 2011 at 13:11:01 (-0600), lrbalt commented:

perhaps later, that will require extra logic.

dnrce avatar Jun 25 '14 16:06 dnrce

On November 11, 2011 at 14:39:06 (-0600), popsch commented:

Then let's leave this open and move it to a later milestone.

dnrce avatar Jun 25 '14 16:06 dnrce

On November 11, 2011 at 14:40:03 (-0600), popsch commented:

Btw. what happens now if you use <context_id> and in the same request? Maybe we should fix it sooner than later.

dnrce avatar Jun 25 '14 16:06 dnrce

On November 11, 2011 at 04:07:21 (-0600), lrbalt commented:

only one way to find out :-)

dnrce avatar Jun 25 '14 16:06 dnrce