(Given all of the spam in this group lately, I don't know if anyone is
reading, but if anyone is...)
I am working on a little app which uses the Hiveminder API. The app
will download tasks and let users modify them offline, syncing changes
back to Hiveminder. I presume that situations may occur where a task
is deleted on Hiveminder.com but still exists in the app. This is
where I am encountering an issue: when I try to do an update of a task
which has already been deleted.
I would expect some sort of error when updating the deleted task, just
like the 404 returned when trying to read it. Instead, the update
creates a new task.
If this is intended behavior, are there any recommendations on how to
tell if a task has been deleted as part of an update operation
(without the side-effect of creating a new task)? I would prefer not
to issue a read request before every update to check for a 404 error.
The app may be running in low-bandwidth situations, and multiple HTTP
requests add up.
Here is an example using curl:
# Create a new task
curl -i -b JIFTY_SID_HIVEMINDER=<COOKIE> -d summary=test1
http://hiveminder.com/=/model/Task.xml
HTTP/1.1 302 Found
Date: Wed, 14 Jan 2009 02:55:59 GMT
Server: Apache
Location:
http://hiveminder.com/=/model/BTDT%3A%3AModel%3A%3ATask/id/584435
Transfer-Encoding: chunked
Content-Type: text/xml; charset=UTF-8
<data>
<action_class>BTDT::Action::CreateTask</action_class>
<content>
<id>584435</id>
</content>
<error></error>
<failure>0</failure>
<field_errors></field_errors>
<field_warnings></field_warnings>
<message>Your task has been created!</message>
<success>1</success>
</data>
# Delete it
curl -i -b JIFTY_SID_HIVEMINDER=<COOKIE>
http://hiveminder.com/=/model/Task/id/584435.xml
curl -i -X DELETE -b JIFTY_SID_HIVEMINDER=<COOKIE>
http://hiveminder.com/=/model/Task/id/584435.xml
HTTP/1.1 302 Found
Date: Wed, 14 Jan 2009 02:58:13 GMT
Server: Apache
Location:
http://hiveminder.com/=/model/BTDT%3A%3AModel%3A%3ATask/id/584435
Transfer-Encoding: chunked
Content-Type: text/xml; charset=UTF-8
<data>
<action_class>BTDT::Action::DeleteTask</action_class>
<content></content>
<error></error>
<failure>0</failure>
<field_errors></field_errors>
<field_warnings></field_warnings>
<message>Deleted task</message>
<success>1</success>
</data>
# Attempt to read it
curl -i -b JIFTY_SID_HIVEMINDER=<COOKIE>
http://hiveminder.com/=/model/Task/id/584435.xml
HTTP/1.1 404
Date: Wed, 14 Jan 2009 02:58:44 GMT
Server: Apache
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1
404 Not Found
# Attempt to update it
curl -X PUT -d summary=test2 -b JIFTY_SID_HIVEMINDER=<COOKIE>
http://hiveminder.com/=/model/Task/id/584435.xml
HTTP/1.1 302 Found
Date: Wed, 14 Jan 2009 03:01:33 GMT
Server: Apache
Location:
http://hiveminder.com/=/model/BTDT%3A%3AModel%3A%3ATask/id/584438
Transfer-Encoding: chunked
Content-Type: text/xml; charset=UTF-8
<data>
<action_class>BTDT::Action::CreateTask</action_class>
<content>
<id>584438</id>
</content>
<error></error>
<failure>0</failure>
<field_errors></field_errors>
<field_warnings></field_warnings>
<message>Your task has been created!</message>
<success>1</success>
</data>
Thanks,
Kris