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 ?
You can easily create a JSON structure which returns any details required. Then showing that to the user is SAP's job.
Hi Stefan ,
Thanks for the response . Can you help me with a sample JSON structure used in realtime create API , if you do not mind so that I will get a clear idea of what you explained me above.
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