Dealing with errors during asynchronous resource creation

Hi Everyone,

I'm searching for a correct solution (not violating the HTTP protocol
and causing least possible confusion to client) to this problem:

I POST a structure with task description to a resource (say /res1) /res1
triggers creation of a resource, which can take a long time and can
potentially fail in the end, due problems in task description (user
fault), that can not be discovered upon the initial POST. I need a way
to communicate this error to the user in case creation fails or
resulting resource in case the execution succeeds.

Would this be correct?

1.) Initial POST to /res1 returns an URI /res2
2.) Subsequent GET or HEAD of /res2 return 202 until the task finishes
3a.) In case the execution succeeds, a GET or HEAD of /res2 returns 200
with task result as body
3b.) Otherwise make the /res2 go away and start returning 410 (or 404?)
and explaining what went wrong in the body?

Or is there a better way?

Thanks,
-- 
Lubomir Rintel (GoodData), phone: #7715

Received on Friday, 9 September 2011 12:31:15 UTC