Re: Modeling conditional update based on existence of a dependent resource
Mike Kelly <[email protected]>
| Newsgroups | gmane.comp.web.services.rest |
|---|---|
| Message-ID | <CANqiZJbTJ4AQJaqJX0rcCtDNxgkHujCXTGKaK6c8MSzFuRS1Jw@mail.gmail.com> |
On Tue, Jul 3, 2012 at 12:45 PM, Dan Haywood <[email protected]>wrote: > ** > > > > > On 3 July 2012 12:38, Mike Kelly <[email protected]> wrote: > >> ** >> >> >> On Tue, Jul 3, 2012 at 12:33 PM, Shaunak Kashyap <[email protected]>wrote: >> >>> ** >>> >>> >>> >>> Using HTTP, if resource A exists, I would like PUT /uri/for/resource/B >>> to succeed. If resource B does not exist, I would like the same PUT request >>> to fail, responding with a status code that indicates to the client that >>> resource A does not exist. So what is a good status code to respond with in >>> the failure case? >>> >> >> Would 404 not suffice here? >> >> > > But the resource being put to DOES exist, so 404 doesn't make sense. > The second sentence starts with "If resource B does not exist", am I missing something? > > To me it's more like a validation error, so consider 422 ("unprocesssable > entity"). > > If 404 really isn't right then 409 Conflict is probably the next best option in this case. Cheers, M