Re: Modeling conditional update based on existence of a dependent resource

Shaunak Kashyap <[email protected]>
Newsgroups gmane.comp.web.services.rest
Message-ID <CAMiVsfKy7vO1zutEuYug7DuzxAOZ0CN-7xqdhG=K7_N=6Uo4bA@mail.gmail.com>
I did intend to say "if resource *A* does not exist", not "resource B".
Apologies for the typo and resulting confusion.

Thank you for the discussion; this is great!

Shaunak

On Tue, Jul 3, 2012 at 5:01 AM, Dan Haywood <[email protected]>wrote:

> **
>
>
>
>
> On 3 July 2012 12:56, Mike Kelly <[email protected]> wrote:
>
>>
>>
>> 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?
>>
>
> Ah... in which case you are right.
>
> However, given the question is phrased as an either/or, I suspect the OP
> meant to say "if resource A does not exist...", in which case 422 or,
> maybe, your 409 might work.
>
> I've asked in the past here about what should be used for validation
> errors, and 422 was the advice I got.  You might have been a respondent on
> one of those threads yourself, Mike.
>
> Dan
>
>
>
>>
>>
>>>
>>> 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
>>
>
>  
>



-- 
"Now the hardness of this world slowly grinds your dreams away / Makin' a
fool's joke out of the promises we make" --- Bruce Springsteen, "Blood
Brothers"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.