Hi all,
I have created an Appian web API that insert record on our server using Appian tables, this API is consumed by SAP to insert data.And it saves data ,but when an error occurs, how we can provide information about the specific input field where the error occured and give a customised error message to the end user.We need help and support from the Appian team to provide a detailed and customized error message for a webapi.
Hope anyone can help us on this scenario?
Discussion posts and replies are publicly visible
In general it is a good practice to validate incoming data before processing it. Then you know, what is wrong and can return that reason in an error message.
Inside a!writeToDataStoreEntity you do not have access to any error details.
Hi Stefan,
I got your valid point about validaton and we are doing it,but we need an extra feature for providing more details about error if incase the api fails.
Is there any way to show the error details in response as our business is asking this as a requirement to make the user experience better, so that user will come to know where they made the mistake while entering the values and why the error occured ?
I would create a new expression which checks each field and creates an error message if something is wrong. This results in a list of dictionaries like
{ {field: "field1", error: "some error here"}, {field: "field42", error: "more errors there"} }
Then when defining the HTTP response, use toJson() to turn that into JSON.
Thank you Stefan,
I believe we have to bring this expression in the OnError() method of API created?I think the response from you will help us.
The a!writeToDataStore has an onError parameter. But I recommend to do the validation before calling that. In case the validation fails, create a separate httpResponse.
Ok Stefan got it , many thanks
I have a same problem. how can i call this customize error msg expression from webapi and how to connect my validation check rule .
I do not understand your question. Please elaborate.
Thank you for your reply.I would like to error check each field before registering and I would like to display a customized error message.
OK. And what exactly do you have trouble with?
how to pair error messages for each field using Expression rules
I really have a hard time understanding what you mean.
In general, you need an expression that conducts all validations and returns a list of text with zero or more error messages.
Then you check for the length of this list and return a HTTP 400 response including that list of errors.