PDA

View Full Version : design question



mess110
June 17th, 2010, 07:59 PM
hello

I am thinking about designing restful api for a weather station but I am curious about how exceptions are handled. I googled around a little bit but I did not find my answer.

How are exceptions supposed to be returned? As xml error or just a string or?

Thanks in advance

diesch
June 17th, 2010, 09:07 PM
I'd use a 4xx or 5xx HTTP response code with a custom reason phrase.

myrtle1908
June 18th, 2010, 01:17 AM
You could also allow the consumer to choose the data interchange format via request headers eg. some clients may prefer standard HTTP error codes, some may prefer to always receive "HTTP 200 OK" with a payload in either XML or JSON.

mess110
June 18th, 2010, 04:34 PM
hm.. ok thank you for the advice :D

implementing..