How do you control Response body output in INavigable with when response code is not a 200

If there is an error (e.g. 401, 500) in the implementation of an INavigable request handler, how do you return a non-200 response code without the platform formatting a canned response as HTML?

This is what I'm doing now:

But, it's returning a 500 error rather than a 401, and it's also returning a block of HTML.  I'd prefer an empty body, or one that I can control based on the expected content type.

Thanks!

Parents Reply
  • It's a custom REST API that implements INavigable because it needs to allow for anonymous users to call it.  But the behavior varies depending on the user's role, so in some cases I need to kick back an error.  All calls should return application/json, except one which returns text/csv.  For the text/csv, I just want to return some plain text, like "Unauthorized".  For the application/json, it would be something like { "Errors" : [ "Unauthorized" ] }.  (or whatever the error actually is).  But, if the response code should be 401, I'd like to see that rather than a 500.

Children