rest - Best HTTP Response Code for a Restful Api which makes calls to other Web Services when a failure occurs -


so i'm designing restful api makes calls other web services aggregates result , return client. if connection of of other web services fails reason, best thing return?

right returning 500 - internal server error client return more details client on made request fail. redundant return 500 http response code response body containing message detailing error occurred or return 503 - service unavailable http response code?

your response code should depend on can request. if clients can expect in case receive partial information , message indicating remote data feeds unavailable, send 200. not include http codes or failing uris in response, names of providers unavailable, , possibly reason why. if do, may find broken when need add non-uri-based providers. if must, make sure include "type" , require clients use it. partially future-proof you, expect many clients ignore type , break if add new types later.

if clients can't partial data, should return 503 because service unavailable. happens unavailable because remote server relies on down. that's no different returning 503 because own database down. api can't return because needs isn't available right now, again later. should include in body of response reason outage, , may include retry-after header if have idea when remote server might available again.

a 404 not appropriate because means resource being requested not exist - error client. resource exist, can't returned right now, because server can't build it.

a 409 not appropriate because there no conflict user can resolve.

a 206 not appropriate because used when request includes range header, , there's no indication these requests do.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -