How to show error messages in the API

0
Hi, I've been trying to apply an error message in my API, but it doesn't return the error message when needed. I've created the following Microflow for my published webservice (below). In this microflow I'm checking if the user has selected on of the three rooms and if he hasn't selected one I want him to receive an error message saying he should select one. Currently I'm just getting an empty API response.
asked
3 answers
1

As extension to Ronald Catersels answer:

Or even better send back a proper error message as part of your result structure, the ThrowWebserviceException is a nasty solution.

Your success result could be:

<result>
 <data>
 ...
</data>
</result>

While your error result is:

<result>
<error>
<code>1</code>
<message>Room should not be empty</message>
</error>
</result>

You could do this without the message and just create some proper documentation about your error codes, since the consuming system will probably not understand human language but would prefer some kind of error code to process the error according to it's own logic.

Hope this helps, Mitchel

answered
0

At first glance it looks like your flow returns an 'empty' if no room-type is selected, which would be consistent with what you see as API output. Or am I missing something?

answered
0

You missed the 'Room should not be empty' message that nobody is able to see ;). That is your mistake. A webservice user is not a normal user that you can present an error message. You should throw a ThrowWebserviceException from the community commons.

Regards,

Ronald

answered