Fork me on GitHub
#clojure-uk
<
2016-09-29
>
mccraigmccraig13:09:25

an HTTP question - i'm creating a sub-resource which causes some upstream actions which may fail, despite the creation of the sub-resource being successful (registering a phone # against a user sends an SMS to the user, which may fail) ... what's the best way of indicating this to a client, which needs to be able to present a "we registered your phone#, try again later for the SMS" to the user... i could use a 502, but 502s can happen for other reasons, so could be a pain to process... does it sound reasonable to put a status-description structure into a 201 to indicate a qualified success ?

otfrom13:09:06

I really think of 5xx as being for truly exceptional things and these don't sound like exceptions as such.

glenjamin13:09:54

imo response code only really matters for what you want intermediaries to do

mccraigmccraig13:09:54

no, something good happened, just not all the good things the user asked for

glenjamin13:09:38

actual end-point applications can’t do enough from response code alone, and have to make sure intermediaries aren’t sending responses that happen to have the same code - so they need to inspect the body anyway

otfrom13:09:59

I think something 2xx and then enough info for the client to decide what (if anything) to do

mccraigmccraig13:09:06

yeah, that's the way i'm leaning too

tcoupland13:09:59

maybe a 201 with a location to where the result of the upstream actions will be available

thomas14:09:00

I like @tcoupland ’s idea…

thomas14:09:15

success and then check later where what the end result it

thomas14:09:38

not 5XX that is really for server failures I think.

rickmoynihan15:09:33

I'd reply with either a 201 or 202 depending on the specifics... 202 is good for communicating that the request was recorded - but its success or failure isn't really known yet - usually because of asynchrony.

rickmoynihan15:09:17

but I'm guessing you don't consider the action to have failed if the sms isn't sent... so 201 is probably best

mccraigmccraig15:09:09

yeah, it has partially succeeded if the sms isn't sent, but the user will want to re-send the sms at some point later

mccraigmccraig15:09:16

i went with 201

korny17:09:07

Some things will automatically raise alerts on 5xx - definitely avoid! I think 2xx + payload is the way to go.

oliy21:09:49

https://http.cat <- choose the cat which seems most appropriate to what you want to do. then use the code it represents