It's all about the answers!

Ask a question

TeamModelledRestService - Set status code for response


Vibha Sinha (1643610) | asked Oct 21 '08, 2:21 a.m.
Hello,

Is there a way I can set the status of the HTTP response object which is returned when I am implementing services which use ITeamModelledRestService interface ?

Thanks
- Vibha

3 answers



permanent link
Patrick Streule (4.9k21) | answered Oct 21 '08, 3:21 a.m.
JAZZ DEVELOPER
Is there a way I can set the status of the HTTP response object which
is returned when I am implementing services which use
ITeamModelledRestService interface ?

You can throw an exception:

ItemNotFoundException -> 404 Not found
IllegalArgumentException -> 400 Bad Request
StaleDataException -> 409 Conflict
TeamRepositoryException -> 500 Internal Server Error
....

Which status code would you like to set?

Regards,
Patrick
Jazz Work Item Team

permanent link
Vibha Sinha (1643610) | answered Oct 24 '08, 1:44 a.m.
It could be either 404, 409 or 500 depending on the exception caught in service implementation code.

permanent link
Patrick Streule (4.9k21) | answered Oct 24 '08, 3:28 a.m.
JAZZ DEVELOPER
It could be either 404, 409 or 500 depending on the exception caught
in service implementation code.

So you could just declare your methods in ITeamModelledRestService with
'throws TeamRepositoryException' and either don't catch the exceptions
if they are already either ItemNotFoundException (404),
StaleDataException (409) or TeamRepositoryException (500 or depending on
the actual subclass).

If you are catching other exceptions, you can throw one of the above to
get the corresponding HTTP status code.

HTH,
Patrick
Jazz Work Item Team

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.